Skip to content

Commit fb837a4

Browse files
author
hersveit
authored
Merge pull request #22 from fullstack-development/update-kit
Update kit
2 parents 37f7478 + 33506a9 commit fb837a4

File tree

107 files changed

+14023
-7354
lines changed

Some content is hidden

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

107 files changed

+14023
-7354
lines changed

.gitignore

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,3 @@
1-
# compiled output
2-
dist
3-
node_modules
4-
env/dev.env
5-
env/prod.env
1+
node_modules/
62

7-
# Logs
8-
logs
9-
*.log
10-
npm-debug.log*
11-
yarn-debug.log*
12-
yarn-error.log*
13-
lerna-debug.log*
14-
15-
# OS
16-
.DS_Store
17-
18-
# Tests
19-
coverage
20-
.nyc_output
21-
22-
# IDEs and editors
23-
.idea
24-
.project
25-
.classpath
26-
.c9/
27-
*.launch
28-
.settings/
29-
*.sublime-workspace
30-
31-
# IDE - VSCode
32-
.vscode/*
3+
.vscode

Dockerfile renamed to Dockerfile.api

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
FROM node:14-alpine as deps
22
RUN apk add --no-cache libc6-compat
33
WORKDIR /app
4-
COPY yarn.lock package.json ./
5-
RUN yarn install --frozen-lockfile --silent
4+
COPY ./api/yarn.lock ./api/package.json ./
5+
COPY ./schema.prisma ./src/schema.prisma
6+
RUN yarn install --ignore-scripts --frozen-lockfile --silent
7+
RUN npx prisma generate --schema="./src/schema.prisma"
68

79
FROM node:14-alpine as builder
810
WORKDIR /app
911
COPY --from=deps /app/node_modules ./node_modules
10-
COPY . .
12+
COPY ./api .
13+
COPY ./schema.prisma ./src/schema.prisma
1114
RUN yarn build
1215

1316
FROM node:14-alpine as runner
@@ -17,6 +20,7 @@ RUN adduser -S nestjs -u 1001
1720

1821
COPY --from=builder --chown=nestjs:nodejs /app/dist ./dist
1922
COPY --from=builder --chown=nestjs:nodejs /app/node_modules ./node_modules
23+
COPY --from=builder --chown=nestjs:nodejs /app/src/swagger.yaml ./src/swagger.yaml
2024

2125
ENV DB_ADDRESS=$DB_ADDRESS
2226
ENV DB_USER=$DB_USER
@@ -28,9 +32,10 @@ ENV JWT_EXPIRES_IN=$JWT_EXPIRES_IN
2832
ENV PORT_API=$PORT_API
2933
ENV JWT_REFRESH_TOKEN_SECRET=$JWT_REFRESH_TOKEN_SECRET
3034
ENV JWT_REFRESH_TOKEN_EXPIRATION_TIME=$JWT_REFRESH_TOKEN_EXPIRATION_TIME
35+
ENV ENVIRONMENT=$ENVIRONMENT
3136

3237
USER nestjs
3338

3439
EXPOSE 3000
3540

36-
CMD ["sh", "-c", "DB_ADDRESS=$DB_ADDRESS DB_USER=$DB_USER DB_PASSWORD=$DB_PASSWORD DB_NAME=$DB_NAME DB_PORT=$DB_PORT JWT_SECRET=$JWT_SECRET JWT_EXPIRES_IN=$JWT_EXPIRES_IN PORT_API=$PORT_API JWT_REFRESH_TOKEN_SECRET=$JWT_REFRESH_TOKEN_SECRET JWT_REFRESH_TOKEN_EXPIRATION_TIME=$JWT_REFRESH_TOKEN_EXPIRATION_TIME NODE_ENV=production node dist/main"]
41+
CMD ["sh", "-c", "ENVIRONMENT=$ENVIRONMENT DB_ADDRESS=$DB_ADDRESS DB_USER=$DB_USER DB_PASSWORD=$DB_PASSWORD DB_NAME=$DB_NAME DB_PORT=$DB_PORT JWT_SECRET=$JWT_SECRET JWT_EXPIRES_IN=$JWT_EXPIRES_IN PORT_API=$PORT_API JWT_REFRESH_TOKEN_SECRET=$JWT_REFRESH_TOKEN_SECRET JWT_REFRESH_TOKEN_EXPIRATION_TIME=$JWT_REFRESH_TOKEN_EXPIRATION_TIME NODE_ENV=production node dist/src/main"]

README.md

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,55 @@
1-
# nestjs-starter-kit
2-
starter kit for node js
1+
# Starter kit Node js
2+
3+
## Links
4+
5+
1. [API doc](./api/Readme.md)
6+
7+
## Preparations
8+
### Installation
9+
10+
Do installations step by step:
11+
12+
1. Install dependencies for `api`
13+
14+
```bash
15+
cd ./api
16+
yarn
17+
```
18+
19+
The postinstall script will generate prisma types for you
20+
21+
`On windows can be not work auto generating prisma schema. You can manual copy schema.prisma in api/src/schema.prisma`
22+
23+
2. Then install dependencies for `e2e`
24+
25+
```bash
26+
cd ./e2e
27+
yarn
28+
```
29+
30+
The postinstall script will generate prisma types for you
31+
32+
`On windows can be not work auto generating prisma schema. You can manual copy schema.prisma in e2e/src/schema.prisma`
33+
34+
### Launch
35+
36+
#### Local with docker
37+
38+
1. Run docker containers via docker-compose from the root folder of the repository
39+
40+
```bash
41+
docker compose -f stk.docker-compose.yaml up -d --build
42+
```
43+
44+
2. Go to `api/env` folder and create copy of `dev.example.env` to `dev.env`
45+
```bash
46+
cd ./api/env
47+
cp ./dev.example.env ./dev.env
48+
```
49+
3. Copy `schema.prisma` from root dir in `api/src/schema.prisma`
50+
4. Go up to `api` and launch migrations
51+
```bash
52+
cd ../
53+
source ./env/dev.env && DATABASE_URL=$DATABASE_URL yarn prisma:migrate:deploy
54+
```
55+
- Press `Yes (y)` if it asks you to install missed dependencies

.dockerignore renamed to api/.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
.git
44
Dockerfile
55
node_modules
6-
eslint-plugin/node_modules
76
dist
87
env
98
coverage
File renamed without changes.
File renamed without changes.

api/.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# compiled output
2+
dist
3+
node_modules
4+
env/dev.env
5+
env/prod.env
6+
7+
# Logs
8+
logs
9+
*.log
10+
npm-debug.log*
11+
yarn-debug.log*
12+
yarn-error.log*
13+
lerna-debug.log*
14+
15+
# OS
16+
.DS_Store
17+
18+
# Tests
19+
coverage
20+
.nyc_output
21+
22+
# IDEs and editors
23+
.idea
24+
.project
25+
.classpath
26+
.c9/
27+
*.launch
28+
.settings/
29+
*.sublime-workspace
30+
31+
# IDE - VSCode
32+
.vscode/*
33+
34+
src/schema.prisma
35+
env/dev.env
36+
env/dev.docker.env
File renamed without changes.

api/.prettierrc.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module.exports = {
2+
bracketSpacing: true,
3+
jsxBracketSameLine: false,
4+
printWidth: 100,
5+
semi: true,
6+
singleQuote: true,
7+
tabWidth: 4,
8+
trailingComma: 'all',
9+
useTabs: false,
10+
endOfLine: 'lf',
11+
overrides: [
12+
{
13+
files: '*.json',
14+
options: {
15+
singleQuote: false,
16+
trailingComma: 'none',
17+
},
18+
},
19+
],
20+
};

api/Dockerfile_test

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
FROM node:16.17-alpine3.15
2+
3+
COPY . /stk
4+
WORKDIR /stk
5+
6+
ENV DB_ADDRESS=$DB_ADDRESS
7+
ENV DB_USER=$DB_USER
8+
ENV DB_PASSWORD=$DB_PASSWORD
9+
ENV DB_NAME=$DB_NAME
10+
ENV DB_PORT=$DB_PORT
11+
ENV JWT_SECRET=$JWT_SECRET
12+
ENV JWT_EXPIRES_IN=$JWT_EXPIRES_IN
13+
ENV PORT_API=$PORT_API
14+
ENV JWT_REFRESH_TOKEN_SECRET=$JWT_REFRESH_TOKEN_SECRET
15+
ENV JWT_REFRESH_TOKEN_EXPIRATION_TIME=$JWT_REFRESH_TOKEN_EXPIRATION_TIME
16+
ENV AUTH_CODE_EXPIRES_IN_MINUTES=$AUTH_CODE_EXPIRES_IN_MINUTES
17+
ENV FULL_PRODUCTION_MODE=$FULL_PRODUCTION_MODE
18+
ENV BLOCKPASS_SECRET_KEY=$BLOCKPASS_SECRET_KEY
19+
ENV BLOCKPASS_CLIENT_ID=$BLOCKPASS_CLIENT_ID
20+
ENV WORKER_HOST=$WORKER_HOST
21+
22+
RUN yarn
23+
RUN yarn build
24+
25+
EXPOSE 3000
26+
27+
CMD ["sh", "-c", "sleep 2 && DATABASE_URL=postgres://${DB_USER}:${DB_PASSWORD}@${DB_ADDRESS}:5432/${DB_NAME} yarn prisma:migrate:dev && WORKER_HOST=$WORKER_HOST BLOCKPASS_CLIENT_ID=$BLOCKPASS_CLIENT_ID BLOCKPASS_SECRET_KEY=$BLOCKPASS_SECRET_KEY FULL_PRODUCTION_MODE=$FULL_PRODUCTION_MODE AUTH_CODE_EXPIRES_IN_MINUTES=$AUTH_CODE_EXPIRES_IN_MINUTES DB_ADDRESS=$DB_ADDRESS DB_USER=$DB_USER DB_PASSWORD=$DB_PASSWORD DB_NAME=$DB_NAME DB_PORT=$DB_PORT JWT_SECRET=$JWT_SECRET JWT_EXPIRES_IN=$JWT_EXPIRES_IN PORT_API=$PORT_API JWT_REFRESH_TOKEN_SECRET=$JWT_REFRESH_TOKEN_SECRET JWT_REFRESH_TOKEN_EXPIRATION_TIME=$JWT_REFRESH_TOKEN_EXPIRATION_TIME yarn start:prod"]

0 commit comments

Comments
 (0)