Skip to content

Commit

Permalink
refactor: remove api prefix on production
Browse files Browse the repository at this point in the history
  • Loading branch information
chertik77 committed Aug 25, 2024
1 parent 78662b6 commit daeda0c
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ CLOUDINARY_CLOUD_NAME=
DATABASE_URL=
ALLOWED_ORIGINS=
PORT=
API_PREFIX=
ACCESS_JWT_SECRET=
REFRESH_JWT_SECRET=
EMAIL_PORT=
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Welcome to the Task Pro App Backend, the powerhouse behind the ultimate tool for

![Screenshot 2024-06-25 at 17 31 06](https://github.com/chertik77/TaskPro-backend/assets/129002577/80c66817-1151-4a9b-91b0-342b387f3810)

_Link to the swagger docs:_ https://api.taskpro.uk/api/docs
_Link to the swagger docs:_ https://api.taskpro.uk/docs

_Link to the frontend repo:_ https://github.com/chertik77/TaskPro-frontend

Expand Down
14 changes: 8 additions & 6 deletions app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,19 @@ export type ResponseError = Error & {

export const app = express()

const apiPrefix = process.env.API_PREFIX

app.use(logger('dev'))
app.use(cors({ origin: process.env.ALLOWED_ORIGINS?.split(',') }))
app.use(express.json())
app.disable('x-powered-by')

app.use('/api/docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument))
app.use('/api/auth', authRouter)
app.use('/api/user', userRouter)
app.use('/api/board', boardRouter)
app.use('/api/column', columnRouter)
app.use('/api/card', cardRouter)
app.use(`${apiPrefix}/docs`, swaggerUi.serve, swaggerUi.setup(swaggerDocument))
app.use(`${apiPrefix}/auth`, authRouter)
app.use(`${apiPrefix}/user`, userRouter)
app.use(`${apiPrefix}/board`, boardRouter)
app.use(`${apiPrefix}/column`, columnRouter)
app.use(`${apiPrefix}/card`, cardRouter)

app.use((_, res) => {
res.status(404).json({ message: 'Not found' })
Expand Down
1 change: 1 addition & 0 deletions app/typings/environment.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ declare global {
REFRESH_JWT_SECRET: string
ALLOWED_ORIGINS: string
PORT: number
API_PREFIX: string
EMAIL_HOST: string
EMAIL_PORT: number
EMAIL_USER: string
Expand Down
2 changes: 1 addition & 1 deletion swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"servers": [
{ "url": "http:localhost:7000/api - Development" },
{ "url": "https://api.taskpro.uk/api - Production" }
{ "url": "https://api.taskpro.uk - Production" }
],
"paths": {
"/auth/signup": {
Expand Down

0 comments on commit daeda0c

Please sign in to comment.