Skip to content

Commit 19581b2

Browse files
author
vaiol
committed
init commit
1 parent f84d76a commit 19581b2

34 files changed

+8998
-0
lines changed

.babelrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"presets": [ "node8" ],
3+
"plugins": [
4+
["transform-runtime", {
5+
"polyfill": false,
6+
"regenerator": true
7+
}]
8+
]
9+
}

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
npm-debug.log

.editorconfig

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

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lib/*.js

.eslintrc.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// http://eslint.org/docs/user-guide/configuring
2+
3+
module.exports = {
4+
root: true,
5+
parser: 'babel-eslint',
6+
parserOptions: {
7+
sourceType: 'module'
8+
},
9+
env: {
10+
browser: false,
11+
},
12+
// https://github.com/standard/standard/blob/master/docs/RULES-en.md
13+
extends: 'standard',
14+
// add your custom rules here
15+
'rules': {
16+
'no-useless-escape': 0,
17+
'comma-dangle': 0,
18+
// allow paren-less arrow functions
19+
'arrow-parens': 0,
20+
// allow async-await
21+
'generator-star-spacing': 0,
22+
// allow debugger during development
23+
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
24+
}
25+
}

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.DS_Store
2+
node_modules/
3+
npm-debug.log
4+
.idea/
5+
lib/
6+
logs/*log
7+
dist/
8+

Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM node:carbon
2+
WORKDIR /usr/src/app
3+
COPY package*.json ./
4+
RUN npm install
5+
COPY . .
6+
7+
EXPOSE 80
8+
VOLUME [ "/usr/src/app" ]

README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
Firebase Cloud Messaging Node.js
2+
===========================================
3+
4+
## API Documentation
5+
https://app.swaggerhub.com/apis/vaiol/npfsb-push/
6+
7+
# Docker version
8+
Docker version of program require only docker and docker compose program installed, web server, postgres and nginx will be provided in docker containers.
9+
10+
## Dependency
11+
- docker
12+
- docker-compose
13+
14+
## Installing
15+
1. Install Docker [guide](https://docs.docker.com/install/linux/docker-ce/ubuntu/)
16+
1. Install Docker Compose [guide](https://docs.docker.com/compose/install/#prerequisites)
17+
18+
## Configuration
19+
Configuring project you must manipulate only with this files:
20+
- docker-compose.prod.yml
21+
- nginx/nginx.conf
22+
- nginx/privkey.pem
23+
- nginx/fullchain.pem
24+
- nginx/dhparam.pem
25+
- conf/serviceAccountKey.json
26+
27+
1. Firebase configuration:
28+
To send your push to users you need to connect your Firebase service account to this program, this could be made by 3 simple steps:
29+
- First of all, you should create service account in Firebase Console, if you have one, skip this step.
30+
To create service account open your Firebase console, then open your application, after that open settings -> service accounts and create one. After creating you will recieve 'serviceAccountKey.json' file also in this page you can find firebase 'databaseURL' strng.
31+
- Put your 'serviceAccountKey.json' into ./config/ folder in the root of project, ou should get ./config/serviceAccountKey.json as result.
32+
- Change FIREBASE_DB environment in admin1 block in docker-compose.prod.yml to your 'databaseURL' of your service account.
33+
1. web configuration:
34+
- You can disable https, create different servers and others just by changing nginx.conf file placed in ./nginx/ folder.
35+
This is simple nginx conf file.
36+
- By default https is enabled, and you couldn't run server without valid ssl key and certificate, so if you want launch server without https you can change nginx.conf file.
37+
- You can change url for checking user session, by change all SESSION_URL environment fields in docker-compose.prod.yml file. By default they are set to `https://lk.npfsb.ru/api/user/authorized`.
38+
1. https configuration:
39+
To start project with HTTPS you need to get SSL certificate and key and connect it to program.
40+
- If you don't have SSL certificate you can get it simply with certbot [guide](https://certbot.eff.org/lets-encrypt/ubuntuxenial-other)
41+
- You should put your private key file to folder ./nginx/ in root of project with name 'privkey.pem', you should get ./nginx/privkey.pem as result. (it is basic name for letsencrypt files)
42+
- You should put your chain of certificate and intermidiate certificate to folder ./nginx/ in root of project with name 'fullchain.pem', you should get ./nginx/fullchain.pem as result. (it is a basic name of letsencrypt)
43+
- You should generate dhparam.pem key and place it to ./nginx/ folder in root of project, you should get ./nginx/dhparam.pem as result.
44+
`openssl dhparam -out ./nginx/dhparam.pem 4096` - command for generating dhparam key (it may take long time).
45+
Or you can use existed key in this folder and do nothing.
46+
1. DB configuration:
47+
DB fully configured to work, make this changes only if you understand what are you doing.
48+
- Change db name, user, and password if needed, fields: POSTGRES_PASSWORD, POSTGRES_DB, POSTGRES_USER.
49+
- If db configurations was changed, changing db connection url also required: field DB_URL in each web block (should be changed 4 urls for web1, web2, web3, admin1 blocks).
50+
- By default postgres will run into the container, and won't be accessible outside. If you want make it accessible, just 'ports' filed in db block should be uncommented. Make sure that you don't have ulready launched postgres instance, port 5432 should be free.
51+
52+
## Build
53+
In root of project:
54+
`docker-compose -f docker-compose.prod.yml up --build`
55+
After project will be builded, (process not finished automatically) you could press `ctrl c` and start it.
56+
57+
## Start
58+
In root of project:
59+
`docker-compose -f docker-compose.prod.yml up -d`
60+
61+
62+
# Manipulation after deploying
63+
### Get Logs
64+
- logs is placed in ./logs/ folder in root of project.
65+
### Get list of all awailable notifications
66+
- conf/notifications.json - is file with all possible notifications to send. (file will be generated after first http request to /admin/send endpoint, so, make your test request)

logs/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)