Skip to content

Commit

Permalink
Base commit - Boilerplate code
Browse files Browse the repository at this point in the history
  • Loading branch information
ashrash committed Oct 15, 2022
0 parents commit 5bf9ae2
Show file tree
Hide file tree
Showing 25 changed files with 10,329 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Multi stage build
FROM node:14.14.0-alpine3.12 as builder
WORKDIR /usr
COPY package.json ./
COPY tsconfig.json ./
COPY src ./src
COPY prod.env .
COPY swagger.yaml .
RUN ls -a
RUN npm install
RUN npm run build


FROM builder as production-build-stage
WORKDIR /usr
COPY package.json ./
COPY prod.env .
COPY swagger.yaml .
RUN npm install --only=production
COPY --from=builder /usr/dist /usr/dist
EXPOSE 3000
CMD ["npm","start"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 R Ashwin

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Node TS BoilerPlate

Tech: Node + Express + MySQL/sequelize + Typescript + Swagger + Docker

CI/CD setup using github action:
## Folder structure
```
├── .github/workflows
├── src
│ ├── config
│ ├── controllers
│ ├── interfaces
│ ├── middleware
│ ├── models
│ ├── routes
│ ├── services
│ ├── tests
│ ├── utils
│ ├── app.ts
│ └── index.ts
```


## Running App in DEV mode
```
#Install dependencies
npm i
#Start app in dev mode. Default port: 3000
npm run dev
```

## Running Tests
Make sure the app is running using the above command.
```
npm run test
```

## Swagger endpoint

``` http://localhost:3000/api-docs ```
41 changes: 41 additions & 0 deletions ecosystem.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
module.exports = {
apps: [
{
name: 'prod',
script: 'dist/server.js',
exec_mode: 'cluster',
instance_var: 'INSTANCE_ID',
instances: 2,
autorestart: true,
watch: false,
ignore_watch: ['node_modules', 'logs'],
max_memory_restart: '1G',
merge_logs: true,
output: './logs/access.log',
error: './logs/error.log',
env: {
PORT: 3000,
NODE_ENV: 'production',
},
},
{
name: 'dev',
script: 'ts-node',
args: '-r tsconfig-paths/register --transpile-only src/server.ts',
exec_mode: 'cluster',
instance_var: 'INSTANCE_ID',
instances: 2,
autorestart: true,
watch: false,
ignore_watch: ['node_modules', 'logs'],
max_memory_restart: '1G',
merge_logs: true,
output: './logs/access.log',
error: './logs/error.log',
env: {
PORT: 3000,
NODE_ENV: 'development',
},
},
]
};
12 changes: 12 additions & 0 deletions nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"watch": [
"src",
".env"
],
"ext": "js,ts,json",
"ignore": [
"src/logs/*",
"src/**/*.{spec,test}.ts"
],
"exec": "ts-node -r tsconfig-paths/register --transpile-only src/index.ts"
}
Loading

0 comments on commit 5bf9ae2

Please sign in to comment.