Skip to content

Commit 75cce08

Browse files
committed
Init Project
0 parents  commit 75cce08

38 files changed

+11713
-0
lines changed

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
# trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false

.env.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
NODE_ENV=development
2+
PORT=3000
3+
JWT_SECRET=bA2xcjpf8y5aSUFsNB2qN5yymUBSs6es3qHoFpGkec75RCeBb8cpKauGefw5qy4
4+
JWT_EXPIRATION_MINUTES=15
5+
MONGO_URI=mongodb://mongodb:xxxxx/ewallet-rest-api
6+
MONGO_URI_TESTS=mongodb://mongodb:xxxxx/ewallet-rest-api

.eslintrc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"rules": {
3+
"no-console": 0,
4+
"no-underscore-dangle": 0,
5+
"no-unused-vars": ["error", { "argsIgnorePattern": "next" }],
6+
"no-use-before-define": ["error", { "variables": false }],
7+
"no-multi-str": 0
8+
},
9+
"env": {
10+
"node": true,
11+
"mocha": true
12+
},
13+
"parserOptions": {
14+
"ecmaVersion": 8
15+
},
16+
"extends": [
17+
"airbnb-base"
18+
]
19+
}

.gitattributes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Convert text file line endings to lf
2+
* text=auto
3+
*.js text
4+
# Denote all files that are truly binary and should not be modified.
5+
*.mp4 binary
6+
*.jpg binary

.gitignore

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Environment variables
2+
.env
3+
4+
# Logs
5+
logs
6+
*.log
7+
npm-debug.log*
8+
9+
# Documentation
10+
docs
11+
12+
# Runtime data
13+
pids
14+
*.pid
15+
*.seed
16+
17+
# Directory for instrumented libs generated by jscoverage/JSCover
18+
lib-cov
19+
20+
# Coverage directory used by tools like istanbul
21+
coverage
22+
23+
# nyc test coverage
24+
.nyc_output
25+
26+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
27+
.grunt
28+
29+
# node-waf configuration
30+
.lock-wscript
31+
32+
# Compiled binary addons (http://nodejs.org/api/addons.html)
33+
build/Release
34+
35+
# Dependency directories
36+
node_modules
37+
jspm_packages
38+
39+
# Optional npm cache directory
40+
.npm
41+
42+
# Optional REPL history
43+
.node_repl_history

.travis.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
language: node_js
2+
node_js: '8'
3+
cache: yarn
4+
5+
git:
6+
depth: 3
7+
8+
branches:
9+
only:
10+
- master
11+
- /^greenkeeper/.*$/
12+
13+
env:
14+
global:
15+
- NODE_ENV=test
16+
- PORT=3000
17+
- JWT_SECRET=bA2xcjpf8y5aSUFsNB2qN5yymUBSs6es3qHoFpGkec75RCeBb8cpKauGefw5qy4
18+
- JWT_EXPIRATION_MINUTES=15
19+
20+
script: yarn validate
21+
22+
before_install: yarn global add greenkeeper-lockfile@1
23+
before_script: greenkeeper-lockfile-update
24+
after_script: greenkeeper-lockfile-upload
25+
26+
# deploy:
27+
# - provider: script
28+
# script: yarn deploy
29+
30+
after_success: yarn coverage

.vscode/launch.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"type": "node",
6+
"request": "launch",
7+
"name": "nodemon",
8+
"runtimeExecutable": "nodemon",
9+
"runtimeArgs": [
10+
"--inspect"
11+
],
12+
"program": "${workspaceRoot}/src/index.js",
13+
"restart": true,
14+
"port": 9229,
15+
"protocol": "inspector",
16+
"console": "integratedTerminal",
17+
"internalConsoleOptions": "neverOpen"
18+
},
19+
{
20+
"type": "node",
21+
"request": "launch",
22+
"name": "node",
23+
"runtimeExecutable": "node",
24+
"runtimeArgs": [
25+
"--inspect"
26+
],
27+
"program": "${workspaceRoot}/src/index.js",
28+
"restart": true,
29+
"port": 9229,
30+
"protocol": "inspector",
31+
"console": "integratedTerminal",
32+
"internalConsoleOptions": "neverOpen"
33+
}
34+
],
35+
"compounds": []
36+
}

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"standard.enable": false
3+
}

Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM node:8-alpine
2+
3+
EXPOSE 3000
4+
5+
ARG NODE_ENV
6+
ENV NODE_ENV $NODE_ENV
7+
8+
RUN mkdir /app
9+
WORKDIR /app
10+
ADD package.json yarn.lock /app/
11+
RUN yarn --pure-lockfile
12+
ADD . /app
13+
14+
CMD ["yarn", "docker:start"]

README.md

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# E-Wallet Rest Api
2+
Using Node.js, Express and MongoDB
3+
4+
## Requirements
5+
6+
- [Node v7.6+](https://nodejs.org/en/download/current/) or [Docker](https://www.docker.com/)
7+
- [Yarn](https://yarnpkg.com/en/docs/install)
8+
9+
## Getting Started
10+
11+
Clone the repo:
12+
13+
```bash
14+
git clone https://github.com/mmucito/ewallet-rest-api.git
15+
cd ewallet-rest-api
16+
```
17+
Install yarn:
18+
19+
```bash
20+
npm install -g yarn
21+
```
22+
23+
Install dependencies:
24+
25+
```bash
26+
yarn
27+
```
28+
29+
Set environment variables:
30+
31+
```bash
32+
cp .env.example .env
33+
```
34+
35+
## Running Locally
36+
37+
```bash
38+
yarn dev
39+
```
40+
41+
## Running in Production
42+
43+
```bash
44+
yarn start
45+
```
46+
47+
## Lint
48+
49+
```bash
50+
# lint code with ESLint
51+
yarn lint
52+
53+
# try to fix ESLint errors
54+
yarn lint:fix
55+
56+
# lint and watch for changes
57+
yarn lint:watch
58+
```
59+
60+
## Test
61+
62+
```bash
63+
# run all tests with Mocha
64+
yarn test
65+
66+
# run unit tests
67+
yarn test:unit
68+
69+
# run integration tests
70+
yarn test:integration
71+
72+
# run all tests and watch for changes
73+
yarn test:watch
74+
75+
# open nyc test coverage reports
76+
yarn coverage
77+
```
78+
79+
## Validate
80+
81+
```bash
82+
# run lint and tests
83+
yarn validate
84+
```
85+
86+
## Logs
87+
88+
```bash
89+
# show logs in production
90+
pm2 logs
91+
```
92+
93+
## Documentation
94+
95+
```bash
96+
# generate and open api documentation
97+
yarn docs
98+
```
99+
100+
## Docker
101+
102+
```bash
103+
# run container locally
104+
yarn docker:dev
105+
or
106+
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up
107+
108+
# run container in production
109+
yarn docker:prod
110+
or
111+
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up
112+
113+
# run tests
114+
yarn docker:test
115+
or
116+
docker-compose -f docker-compose.yml -f docker-compose.test.yml up
117+
```
118+
119+
## Deploy
120+
121+
Set your server ip:
122+
123+
```bash
124+
DEPLOY_SERVER=127.0.0.1
125+
```
126+
127+
Replace my Docker username with yours:
128+
129+
```bash
130+
nano deploy.sh
131+
```
132+
133+
Run deploy script:
134+
135+
```bash
136+
yarn deploy
137+
or
138+
sh ./deploy.sh
139+
```
140+
141+
142+
## License
143+
This project is licensed under the [MIT License](https://github.com/mmucito/ewallet-rest-api/blob/master/LICENSE)

0 commit comments

Comments
 (0)