Skip to content

Commit db144c3

Browse files
committedJul 8, 2022
Update backend
1 parent e967b23 commit db144c3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+3154
-5976
lines changed
 

‎.eslintrc

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"ignorePatterns": ["src/db/seeders/*.js"],
3+
"plugins": ["prettier"],
4+
"env": {
5+
"browser": true,
6+
"node": true,
7+
"es2021": true
8+
},
9+
"extends": "eslint:recommended",
10+
"parserOptions": {
11+
"ecmaVersion": 12,
12+
"sourceType": "module"
13+
},
14+
"rules": {
15+
"no-unused-vars": ["error", { "vars": "all", "args": "none", "ignoreRestSiblings": true }],
16+
"prettier/prettier": [
17+
"warn",
18+
{
19+
"usePrettierrc": false,
20+
"printWidth": 100,
21+
"tabWidth": 2,
22+
"useTabs": false,
23+
"semi": true,
24+
"singleQuote": true,
25+
"trailingComma": "all",
26+
"endOfLine": "lf",
27+
"arrowParens": "avoid"
28+
}
29+
]
30+
}
31+
}

‎README.md

+28-22
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,41 @@
1818
- `sudo apt update`
1919
- `sudo apt install postgresql postgresql-contrib`
2020

21-
###### 2. Install sequelize-cli:
22-
- `sudo npm install -g sequelize-cli`
23-
24-
###### 3. Create db and admin user:
21+
###### 2. Create db and admin user:
2522
- Before run and test connection, make sure you have created a database as described in the above configuration. You can use the `psql` command to create a user and database.
26-
- `psql postgres --u postgres`
27-
28-
- Next, type this command for creating a new user with password then give access for creating the database.
29-
- `postgres-# CREATE ROLE admin WITH LOGIN PASSWORD 'admin_pass';`
30-
- `postgres-# ALTER ROLE admin CREATEDB;`
31-
32-
- Quit `psql` then log in again using the new user that previously created.
33-
- `postgres-# \q`
34-
- `psql postgres -U admin`
23+
- `psql -U postgres`
3524

3625
- Type this command to creating a new database.
37-
- `postgres=> CREATE DATABASE nodejs_backend_db;`
38-
39-
- Then give that new user privileges to the new database then quit the `psql`.
40-
- `postgres=> GRANT ALL PRIVILEGES ON DATABASE nodejs_backend_db TO admin;`
26+
- `postgres=> CREATE DATABASE development OWNER postgres;`
4127
- `postgres=> \q`
42-
43-
###### 4. Run db migrations and seeds:
44-
- `sequelize db:migrate && sequelize db:seed:all`
4528

4629
------------
30+
31+
##### Setup database tables:
32+
- `yarn reset`
4733

4834
##### Start development build:
4935
- `yarn start:dev`
50-
36+
5137
##### Start production build:
52-
- `yarn start`
38+
- `yarn start`
39+
40+
------------
41+
42+
#### Api Documentation (Swagger)
43+
44+
http://localhost:8080/api-docs (local host)
45+
46+
http://host_name/api-docs
47+
48+
------------
49+
50+
##### Docker:
51+
52+
See instructions in a `docker` folder if you want to run this backend alongside with a frontend and a database.
53+
In this case you don't need to build docker image manually and run commands below.
54+
55+
1. Make sure you have Postgres installed locally like in [Adjust local db](#adjust-local-db):
56+
2. Build an image `docker build -t um-backend-image .`
57+
3. Run a container `docker run -p 8080:8080 -d um-backend-image`
58+
4. Now the api should be available by `http://localhost:8080/api`

0 commit comments

Comments
 (0)
Please sign in to comment.