Skip to content

Commit 5f3c86f

Browse files
committed
Release the MongoDB version
1 parent e133fad commit 5f3c86f

25 files changed

+879
-0
lines changed

.eslintrc.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module.exports = {
2+
env: {
3+
es2021: true,
4+
node: true,
5+
},
6+
extends: ['airbnb-typescript/base', 'plugin:@typescript-eslint/recommended'],
7+
parser: '@typescript-eslint/parser',
8+
parserOptions: {
9+
ecmaVersion: 2018,
10+
sourceType: 'module',
11+
project: './tsconfig.json',
12+
},
13+
rules: {
14+
'@typescript-eslint/explicit-module-boundary-types': 'off',
15+
'no-param-reassign': 'off',
16+
'no-underscore-dangle': 'off',
17+
'consistent-return': 'off',
18+
'no-console': 'off',
19+
},
20+
};

.gitattributes

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Declare files that will always have LF line endings on checkout.
2+
3+
*.html text eol=lf
4+
*.scss text eol=lf
5+
*.sass text eol=lf
6+
*.css text eol=lf
7+
*.js text eol=lf
8+
*.json text eol=lf
9+
*.svg text eol=lf
10+
*.yml text eol=lf
11+
*.yaml text eol=lf
12+
*.md text eol=lf
13+
14+
.babelrc text eol=lf
15+
.gitignore text eol=lf
16+
.gitattributes text eol=lf
17+
18+
LICENSE text eol=lf
19+
20+
# Denote all files that are truly binary and should not be modified.
21+
22+
*.png binary
23+
*.jpg binary
24+
*.jpeg binary
25+
*.gif binary
26+
*.bmp binary
27+
*.ai binary
28+
*.psd binary
29+
*.pdf binary
30+
31+
*.otf binary
32+
*.eot binary
33+
*.ttf binary
34+
*.woff binary
35+
*.woff2 binary
36+
*.zip binary
37+
*.rar binary

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
build
3+
database.db

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v14

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Change Log
2+
3+
## [v1.0.0] 2022-06-18
4+
### Stable release - Mongo branch
5+
6+
- Stack: NodeJS / Express / MongoDB / Mongoose
7+
- API:
8+
- Sign UP: `/api/users/register`
9+
- Sign IN: `/api/users/login`
10+
- Logout: `/api/users/logout`
11+
- Check Session: `/api/users/checkSession`
12+
- Edit User: `/api/users/edit`
13+
- Data persistence
14+
- MongoDB / Mongoose

README.md

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
2+
# Nodejs API Server (Mongo)
3+
4+
Simple starter built with Typescrypt / Express / MongoDB and JWT Auth powered by **Passport** library - provided and actively supported by **AppSeed** [App Generator](https://appseed.us/app-generator). The authentication flow is based on [json web tokens](https://jwt.io) and `passport-jwt` strategy - Inspired by other great OSS starters mentioned in the [credits](#credits) section.
5+
6+
<br />
7+
8+
> Features:
9+
10+
- Simple, intuitive codebase - built for beginners (can be extended with ease)
11+
- Node JS / Express / MongoDB
12+
- Typescript
13+
- Auth: Passport / `passport-jwt` strategy
14+
- [API Interface Descriptor](https://github.com/app-generator/api-server-nodejs/blob/master/media/api.postman_collection.json): POSTMAN Collection
15+
- Docker
16+
- Full-stack Samples that uses this backend
17+
- [React Node JS Datta](https://appseed.us/product/react-node-js-datta-able) - open-source full-stack sample
18+
- [React Node JS Berry](https://appseed.us/product/react-node-js-berry-dashboard) - open-source full-stack sample
19+
20+
<br />
21+
22+
> Support:
23+
24+
- Github (issues tracker), Email: **support @ appseed.us**
25+
- **Discord**: [LIVE Support](https://discord.gg/fZC6hup) (registered AppSeed Users)
26+
27+
<br />
28+
29+
![Nodejs API Server - Open-source Nodejs Starter provided by AppSeed.](https://user-images.githubusercontent.com/51070104/124414813-142aa180-dd5c-11eb-9279-6b082dadc51a.png)
30+
31+
<br />
32+
33+
## Requirements
34+
35+
- [Node.js](https://nodejs.org/) >= 10.x
36+
- [MongoDB](https://www.mongodb.com/) server
37+
38+
<br />
39+
40+
## How to use the code
41+
42+
**Clone the sources**
43+
44+
```bash
45+
$ git clone https://github.com/app-generator/api-server-nodejs-mongo.git
46+
$ cd api-server-nodejs-mongo
47+
```
48+
49+
**Install dependencies** via NPM or Yarn
50+
51+
```bash
52+
$ npm i
53+
// OR
54+
$ yarn
55+
```
56+
57+
**Start the API server** - development mode
58+
59+
```bash
60+
$ npm dev
61+
// OR
62+
$ yarn dev
63+
```
64+
65+
**Start the API server** - for production (files served from `build/build/index.js`)
66+
67+
```bash
68+
$ npm start
69+
// OR
70+
$ yarn start
71+
```
72+
73+
The API server will start using the `PORT` specified in `.env` file (default 5000)
74+
75+
<br />
76+
77+
## Codebase Structure
78+
79+
```bash
80+
< ROOT / src >
81+
|
82+
|-- config/
83+
| |-- config.ts # Configuration
84+
| |-- passport.ts # Define Passport Strategy
85+
|
86+
|-- models/
87+
| |-- activeSession.ts # Sessions Model (Mongo)
88+
| |-- user.ts # User Model (Mongo)
89+
|
90+
|-- routes/
91+
| |-- users.ts # Define Users API Routes
92+
|
93+
|
94+
|-- index.js # API Entry Point
95+
|-- .env # Specify the ENV variables
96+
|
97+
|-- ************************************************************************
98+
```
99+
100+
<br />
101+
102+
## Mongo Settings
103+
104+
The Mongo URI lives in `config/keys.js`
105+
106+
```javascript
107+
... = 'mongodb://localhost/api_server_nodejs'
108+
```
109+
110+
<br />
111+
112+
## API
113+
114+
For a fast set up, use this POSTMAN file: [api_sample](https://github.com/app-generator/api-server-nodejs/blob/master/media/api.postman_collection.json)
115+
116+
> **Register** - `api/users/signup`
117+
118+
```
119+
POST api/users/signup
120+
Content-Type: application/json
121+
122+
{
123+
"username":"test",
124+
"password":"pass",
125+
"email":"test@appseed.us"
126+
}
127+
```
128+
129+
<br />
130+
131+
> **Login** - `api/users/login`
132+
133+
```
134+
POST /api/users/login
135+
Content-Type: application/json
136+
137+
{
138+
"password":"pass",
139+
"email":"test@appseed.us"
140+
}
141+
```
142+
143+
<br />
144+
145+
> **Logout** - `api/users/logout`
146+
147+
```
148+
POST api/users/logout
149+
Content-Type: application/json
150+
authorization: JWT_TOKEN (returned by Login request)
151+
152+
{
153+
"token":"JWT_TOKEN"
154+
}
155+
```
156+
157+
<br />
158+
159+
## License
160+
161+
MIT @ [AppSeed](https://appseed.us)
162+
163+
<br />
164+
165+
## Credits
166+
167+
This software is provided by the core AppSeed team with an inspiration from other great NodeJS starters:
168+
169+
- Initial verison - coded by [Teo Deleanu](https://www.linkedin.com/in/teodeleanu/)
170+
- [Hackathon Starter](https://github.com/sahat/hackathon-starter) - A truly amazing boilerplate for Node.js apps
171+
- [Node Server Boilerplate](https://github.com/hagopj13/node-express-boilerplate) - just another cool starter
172+
- [React NodeJS Argon](https://github.com/creativetimofficial/argon-dashboard-react-nodejs) - released by **Creative-Tim** and [ProjectData](https://projectdata.dev/)
173+
174+
<br />
175+
176+
---
177+
[Nodejs Starter](https://appseed.us/boilerplate-code/nodejs-starter) - provided by AppSeed [App Generator](https://appseed.us)

docker-compose.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
version: '3.8'
2+
3+
services:
4+
priv-api-server-nodejs:
5+
container_name: api-server-nodejs
6+
container_name: priv-api-server-nodejs
7+
image: priv-api-server-nodejs
8+
restart: unless-stopped
9+
environment:
10+
NODE_ENV: 'production'
11+
PORT: '5000'
12+
MONGO_URI: 'mongodb://mongo:27017/api_server_nodejs'
13+
SECRET: 'SuperS3cret_4277m'
14+
ports:
15+
- '5000:5000'
16+
depends_on:
17+
- mongo
18+
volumes:
19+
- .:/usr/src/priv-api-server-nodejs
20+
networks:
21+
- node-network
22+
23+
mongo:
24+
container_name: mongodb
25+
image: mongo:4.2.1-bionic
26+
restart: unless-stopped
27+
environment:
28+
MONGO_INITDB_DATABASE: api_server_nodejs
29+
ports:
30+
- '27017:27017'
31+
volumes:
32+
- dbdata:/data/db
33+
networks:
34+
- node-network
35+
36+
volumes:
37+
dbdata:
38+
39+
networks:
40+
node-network:
41+
driver: bridge

dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM node:lts-alpine AS deps
2+
3+
WORKDIR /opt/app
4+
COPY package.json yarn.lock ./
5+
RUN yarn install --frozen-lockfile
6+
7+
FROM node:lts-alpine AS builder
8+
9+
ENV NODE_ENV=production
10+
WORKDIR /opt/app
11+
COPY . .
12+
COPY --from=deps /opt/app/node_modules ./node_modules
13+
RUN yarn build
14+
15+
FROM node:lts-alpine AS runner
16+
17+
WORKDIR /opt/app
18+
ENV NODE_ENV=production
19+
USER node
20+
COPY --from=builder /opt/app/package.json ./
21+
COPY --from=builder /opt/app/node_modules ./node_modules
22+
COPY --from=builder /opt/app/build ./build
23+
COPY --from=builder /opt/app/production.config.json ./
24+
EXPOSE 5000
25+
ENTRYPOINT ["npm"]
26+
CMD ["run", "start-node"]

env.sample

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
NODE_ENV=DEV
2+
PORT=5000
3+
MONGO_URI="mongodb://localhost:27017/api_server_nodejs"
4+
SECRET="STRONG_PASS_HERE"

jest.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
transform: {
3+
'^.+\\.ts?$': 'ts-jest',
4+
},
5+
setupFiles: ['dotenv/config'],
6+
testEnvironment: 'node',
7+
coveragePathIgnorePatterns: ['node_modules'],
8+
coverageReporters: ['text', 'lcov', 'clover', 'html'],
9+
};

package copy.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "boilerplate-code-django",
3+
"mastertemplate": "boilerplate-code-django",
4+
"version": "1.0.4",
5+
"description": "Template project - Django Boilerplate Code",
6+
"scripts": {},
7+
"repository": {
8+
"type": "git",
9+
"url": "https://github.com/app-generator/boilerplate-code-django"
10+
},
11+
"bugs": {
12+
"url": "https://github.com/app-generator/boilerplate-code-django/issues",
13+
"email": "support@appseed.us"
14+
},
15+
"author": "AppSeed App Generator <support@appseed.us> (https://appseed.us)",
16+
"engines": {
17+
"node": ">=10.0.0"
18+
},
19+
"dependencies": {},
20+
"devDependencies": {}
21+
}

0 commit comments

Comments
 (0)