Skip to content

Commit

Permalink
feat: remove base controller
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoanle396 committed Aug 2, 2024
1 parent 92480d1 commit 76bc281
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 61 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
branches:
- demo
env:
CRAWL_API_URL: ${{ vars.CRAWL_API_URL }}
AUTH_TOKEN: ${{ vars.AUTH_TOKEN }}

jobs:
Expand Down Expand Up @@ -49,7 +50,7 @@ jobs:
output: ${{needs.handle-commit.outputs.output}}
run: |
echo $output
echo "$output"
echo "${{ env.CRAWL_API_URL }}$output"
curl --request GET \
--url "$output" \
--header "Authorization: Bearer $AUTH_TOKEN"
--url "${{ env.CRAWL_API_URL }}$output" \
--header "Authorization: Bearer ${{ env.AUTH_TOKEN }}"
2 changes: 2 additions & 0 deletions apps/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"start": "node -r ./tsconfig-paths.js dist/index.js",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"crawl": "ts-node -r tsconfig-paths/register src/crawl.ts",
"seed": "ts-node -r tsconfig-paths/register src/seed.ts",
"seed:prod": "node -r ./tsconfig-paths.js dist/seed.js",
"test": "ts-node -r tsconfig-paths/register src/test.ts"
},
"keywords": [],
Expand Down
32 changes: 0 additions & 32 deletions apps/server/src/controllers/base.controller.ts

This file was deleted.

7 changes: 1 addition & 6 deletions apps/server/src/crawl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,14 @@ export function fromFileChangesToQuery(fileChanges: Array<string>): string {
return dataReturn
}

export function getURL(data: string) {
const server = 'https://44d7-42-119-180-122.ngrok-free.app'

return `${server}/api/v1/crawl${data}`
}

async function main() {
// get list file change
const fileChanges = await getListFileChange()

const query: string = fromFileChangesToQuery(fileChanges)

console.log(`${getURL(query)}`)
console.log(`${query}`)
}

main()
Expand Down
2 changes: 0 additions & 2 deletions apps/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ import App from './App'
import CategoriesRoute from './routes/categories.route'
import ProjectsRoute from './routes/projects.route'
import TagsRoute from './routes/tags.route'
import { BaseRoute } from './routes/base.route'
import { CrawlRoute } from './routes/crawl.route'

const app = new App([
new CategoriesRoute(),
new ProjectsRoute(),
new TagsRoute(),
new BaseRoute(),
new CrawlRoute(),
])

Expand Down
18 changes: 0 additions & 18 deletions apps/server/src/routes/base.route.ts

This file was deleted.

35 changes: 35 additions & 0 deletions apps/server/src/seed.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { creatorParentCategory } from '@/creator/creatorParentCategory'
import { creatorSocial } from '@/creator/creatorSocial'
import { fsWrapper } from '@/utils/fs/fsWrapper'
import 'dotenv/config'
import { logger } from './utils/logger'
import { connection } from './databases/connection'

function createCategory(parentFolders) {
parentFolders.map((folder) => {
const path = `/projects/${folder}`
creatorParentCategory(path)
})
}

const main = async () => {
try {
connection.initialize()
await creatorSocial()
const rootHierachy = await fsWrapper.readdir(`/projects`)
const parentFolders = rootHierachy.filter(
(value) => value !== 'projects.json' && value !== 'socials.json',
)

createCategory(parentFolders)
console.log('\x1b[32m databases build successfully \x1b[0m')
logger.verbose('databases build successfully')
process.exit()
} catch (error) {
console.error(error)
logger.error(error)
process.exit(1)
}
}

main()

0 comments on commit 76bc281

Please sign in to comment.