Skip to content

Commit

Permalink
feat(1.1c): Use ES syntax and Async handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
one-aalam committed Jul 12, 2021
1 parent 7abbc25 commit 07e16e8
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,12 @@ const APP_PORT = process.env.APP_PORT || 3000

const server = Fastify()

server.get('/users', (req, res) => {
res.send(USERS)
})
server.get('/users', async () => USERS)

server.get('/recipes', (req, res) => {
res.send(RECIPES)
})
server.get('/recipes', async () => RECIPES)

server.get('/categories', (req, res) => {
res.send(RECIPE_CATEGORIES)
})
server.get('/categories', async () => RECIPE_CATEGORIES)

server.get('*', (req, res) => {
res.send(`You requested for ${req.url} using method ${req.method}, which does not have an associated response`)
})
server.get('*', async (req) => `You requested for ${req.url} using method ${req.method}, which does not have an associated response`)

server.listen(APP_PORT, () => console.log(`Server started on ${APP_PORT} 🚀`));

0 comments on commit 07e16e8

Please sign in to comment.