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
version: "3.2" | |
services: | |
web: | |
image: aerabi/express-ts | |
build: . | |
ports: | |
- "3000:3000" | |
environment: | |
NODE_ENV : docker | |
volumes: |
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:12.10 | |
RUN mkdir -p /usr/src/app | |
WORKDIR /usr/src/app | |
COPY package.json /usr/src/app/ | |
RUN npm install | |
COPY . /usr/src/app | |
RUN npm run build:all |
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
{ | |
... | |
"scripts": { | |
"build:routes": "mkdir -p src/routes && tsoa routes", | |
"build:swagger": "mkdir -p api && mkdir -p api/dist && tsoa swagger", | |
"build:ts": "tsc -p src", | |
"build:all": "npm run build:routes && npm run build:swagger && npm run build:ts", | |
"server": "node dist/main.js", | |
"lint": "tslint -c tslint.json 'src/**/*.ts'" | |
}, |
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 * as express from 'express'; | |
import * as fs from 'fs'; | |
import * as https from 'https'; | |
import { RegisterRoutes } from './routes/routes'; | |
const privateKey = fs.readFileSync('cert/cert.key'); | |
const certificate = fs.readFileSync('cert/cert.crt'); | |
const credentials = {key: privateKey, cert: certificate}; | |
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 * as express from 'express'; | |
import { RegisterRoutes } from './routes/routes'; // here | |
const app = express(); | |
const port = 3000; | |
RegisterRoutes(app); // and here | |
app.listen(port, () => console.log(`Server started listening to port ${port}`)); |
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
Show hidden characters
{ | |
"compilerOptions": { | |
"experimentalDecorators": true, // this line | |
"outDir": "../dist", | |
"baseUrl": "", | |
"module": "commonjs" | |
} | |
} |
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 { Controller, Get, Route } from 'tsoa'; | |
@Route('') | |
export class IndexController extends Controller { | |
@Get('') | |
public async index() { | |
return { msg: 'Hello World!' }; | |
} | |
@Get('/msg') |
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
{ | |
"swagger": { | |
"basePath": "/api/v1", | |
"entryFile": "./src/main.ts", | |
"specVersion": 3, | |
"outputDirectory": "./api/dist", | |
"controllerPathGlobs": [ | |
"./src/controllers/**/*controller.ts" | |
] | |
}, |
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
{ | |
"compilerOptions": { | |
"outDir": "../dist", | |
"baseUrl": "", | |
"module": "commonjs" | |
} | |
} |
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": "simple-express", | |
"version": "0.0.1", | |
"description": "A simple Express.js app", | |
"main": "src/main.ts", | |
"dependencies": { | |
"express": "^4.17.1" | |
}, | |
"devDependencies": { | |
"typescript": "^3.6.4" |
NewerOlder