Last active
May 8, 2020 21:14
-
-
Save SilentImp/bb1ec4e931683f1b82b3c7e6374887a9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:13-alpine AS base | |
RUN mkdir -p /var/app && chown -R node /var/app | |
WORKDIR /var/app | |
COPY package.json . | |
COPY package-lock.json . | |
COPY index.mjs . | |
ENV NODE_ENV=production | |
RUN apk add --update bash | |
RUN npm ci --only=prod --silent | |
EXPOSE 3000 | |
CMD node --experimental-modules index.mjs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fastify from 'fastify'; | |
const server = fastify({ logger: true }); | |
const PORT = 3000; | |
server.get('/', async (request, reply) => { | |
reply.code(200).header('Content-Type', 'application/json; charset=utf-8').send({"hello":"world"}); | |
}); | |
server.post('/', async (request, reply) => { | |
server.log.error(request); | |
reply.code(200); | |
}); | |
const start = async () => { | |
try { | |
await server.listen(PORT); | |
} catch (error) { | |
server.log.error(error); | |
process.exit(1); | |
} | |
} | |
start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment