This file contains 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
{ | |
"name": "express-project", | |
"version": "1.0.0", | |
"description": "", | |
"main": "src/index.js", | |
"scripts": { | |
"build": "babel src -d dist --copy-files", | |
"dev": "babel-watch -w src -w .env src/index.js", | |
"start": "node dist/index.js", | |
"test": "cross-env NODE_ENV=test jest --verbose", |
This file contains 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 app from './app' | |
import config from './config' | |
app.listen(config.port, ()=>{ | |
console.log(`🚀 ${config.app.name} version ${config.app.version} 🚀`) | |
console.log(`🚀 Listening on port ${config.port} in ${config.nodeEnv} mode 🚀`) | |
}) |
This file contains 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 config from '../../config' | |
/** | |
* Health check endpoint | |
* @param {import('express').Request} req | |
* @param {import('express').Response} res | |
*/ | |
const getRoot = (req, res) => { | |
return res.json(config.app) | |
} |
This file contains 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
{ | |
"modulePathIgnorePatterns": ["/dist/"], | |
"transform": { | |
"^.+\\.js$": "babel-jest" | |
} | |
} |
This file contains 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 dotenv from 'dotenv'; | |
import packageJson from '../package.json' | |
dotenv.config() | |
const config = { | |
app: { | |
name: packageJson.name, | |
description: packageJson.description, | |
version: packageJson.version |
This file contains 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 cors from 'cors'; | |
import config from './config'; | |
import express from 'express'; | |
import helmet from 'helmet'; | |
import morgan from 'morgan'; | |
import errorHandler from './middleware/errorHandler'; | |
import fourOhFour from './middleware/fourOhFour'; | |
import root from './routes/root'; | |
const app = express() |
This file contains 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 dotenv from 'dotenv'; | |
dotenv.config() | |
const config = { | |
nodeEnv: process.env['NODE_ENV'] ?? 'development', | |
origin: process.env['ORIGIN'] ?? '*', | |
port: process.env['PORT'] ?? 3000 | |
} | |
export default config |
This file contains 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
node_modules | |
dist | |
.env* | |
.git |
This file contains 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:16-alpine as ts-environment | |
WORKDIR /usr/app | |
COPY package.json ./ | |
COPY package-lock.json ./ | |
RUN npm install | |
COPY . ./ |
This file contains 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
{ | |
"name": "express-project", | |
"version": "1.0.0", | |
"description": "", | |
"main": "src/index.js", | |
"scripts": { | |
"build": "babel src -d dist --copy-files", | |
"dev": "babel-watch -w src -w .env src/index.js", | |
"start": "node dist/index.js", | |
"test": "jest --verbose", |
NewerOlder