Skip to content

Commit 3f0826f

Browse files
committed
initializing the project -> add build configurations
0 parents  commit 3f0826f

23 files changed

+14605
-0
lines changed

.babelrc

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"presets": [
3+
[
4+
"@babel/preset-env",
5+
{
6+
"targets": {
7+
"node": "current"
8+
}
9+
}
10+
],
11+
"@babel/preset-typescript"
12+
]
13+
}

.dockerignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/node_modules
2+
npm-debug.log

.editorconfig

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
max_line_length = 70
8+
9+
# Matches multiple files with brace expansion notation
10+
# Set default charset
11+
[*.{js,ts}]
12+
charset = utf-8
13+
14+
trim_trailing_whitespace = true
15+
insert_final_newline = true

.eslintignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/node_modules
2+
/tests
3+
/dist
4+
jest.config.js

.eslintrc

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"extends": [
3+
"eslint:recommended",
4+
"plugin:@typescript-eslint/eslint-recommended",
5+
"plugin:@typescript-eslint/recommended",
6+
"prettier"
7+
],
8+
"plugins": ["@typescript-eslint", "no-loops", "import"],
9+
"parserOptions": {
10+
"ecmaVersion": "latest",
11+
"sourceType": "module"
12+
},
13+
"rules": {
14+
"no-useless-escape": "off",
15+
"no-undef": "off",
16+
"no-console": "warn",
17+
"no-alert": "error",
18+
"camelcase": "error",
19+
"no-loops/no-loops": "error",
20+
"@typescript-eslint/no-inferrable-types": "off"
21+
},
22+
"env": {
23+
"node": true,
24+
"es6": true
25+
}
26+
}

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
# Keep environment variables out of version control
3+
.env

.prettierignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/public
2+
/coverage
3+
/dist
4+
jest.confi.js

.prettierrc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"trailingComma": "all",
3+
"semi": true,
4+
"singleQuote": false,
5+
"tabWidth": 2,
6+
"printWidth": 70
7+
}

Dockerfile

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
FROM node:16-alpine AS base
2+
3+
# Not intended to be verbose
4+
ARG NPM_LOG_LEVEL=silent
5+
# Hide Open Collective message from install logs
6+
ENV OPENCOLLECTIVE_HIDE=1
7+
# Hide NPM security message from install logs
8+
ENV NPM_CONFIG_AUDIT=false
9+
# Hide NPM funding message from install logs
10+
ENV NPM_CONFIG_FUND=false
11+
12+
# Update npm to version 7
13+
RUN npm i -g [email protected]
14+
15+
# Set the working directory
16+
WORKDIR /app/server
17+
18+
# Copy files specifying dependencies
19+
COPY package.json package-lock.json ./
20+
21+
# Install dependencies
22+
RUN npm ci --loglevel=$NPM_LOG_LEVEL;
23+
24+
# Copy Prisma schema
25+
COPY prisma/schema.prisma ./prisma/
26+
27+
# Generate Prisma client
28+
RUN npm run prisma:generate;
29+
30+
# Copy all the files
31+
COPY . .
32+
33+
# Build code - genearets a dist folder from the contents of the src folder
34+
RUN npm run build
35+
36+
# Expose the port the server listens to
37+
EXPOSE 4000
38+
39+
# Run server
40+
CMD [ "node", "dist/index.js"]

README.md

Whitespace-only changes.

dist/index.js

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docker-compose.db.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: "3"
2+
services:
3+
db:
4+
image: postgres:12
5+
ports:
6+
- "${POSTGRESQL_PORT}:5432"
7+
environment:
8+
POSTGRES_USER: ${POSTGRESQL_USER}
9+
POSTGRES_PASSWORD: ${POSTGRESQL_PASSWORD}
10+
volumes:
11+
- postgres:/var/lib/postgresql/data
12+
13+
#for data to persist
14+
volumes:
15+
postgres: ~

docker-compose.yml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# I will use this file only in the proudction for deployment
2+
# I might not use it whatsoever if I don't find a good place to host it lol
3+
4+
# To summaize: Create a DB (postgres image) service -> Create Migrations on the Database (if any, but yet an important step just in case the migration has changed or something) -> Pick the configurations from Dockerfile and run the server on the specified port
5+
6+
version: "3"
7+
services:
8+
server:
9+
build:
10+
#make use of Dockerfile
11+
context: .
12+
args:
13+
NPM_LOG_LEVEL: notice
14+
ports:
15+
- "${PORT}:4000"
16+
environment:
17+
DATABASE_URL: "${DATABASE_URL}"
18+
depends_on:
19+
- migration
20+
21+
migration:
22+
build:
23+
context: .
24+
args:
25+
NPM_LOG_LEVEL: notice
26+
command: npm run db:init
27+
working_dir: /app/server
28+
environment:
29+
DATABASE_URL: "${DATABASE_URL}"
30+
depends_on:
31+
db:
32+
condition: service_healthy
33+
34+
#Same service as docker-compose.db.yaml - docker-compose.db.yml is for someone who doesn't want to use this docker-compose.yaml for building
35+
db:
36+
image: postgres:12
37+
environment:
38+
POSTGRES_USER: ${POSTGRESQL_USER}
39+
POSTGRES_PASSWORD: ${POSTGRESQL_PASSWORD}
40+
ports: ${POSTGRESQL_PORT}:5432
41+
volumes:
42+
- postgres:/var/lib/postgresql/data
43+
healthcheck:
44+
test:
45+
[
46+
"CMD",
47+
"pg_isready",
48+
"-q",
49+
"-d",
50+
"${POSTGRESQL_DB_NAME}",
51+
"-U",
52+
"${POSTGRESQL_USER}",
53+
]
54+
timeout: 45s
55+
interval: 10s
56+
retries: 10
57+
58+
#should add a redis image too
59+
60+
#for data to persist
61+
volumes:
62+
postgres: ~

jest.config.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
testEnvironment: "node", //deafult is jsdom i.e test envrionment
3+
testRegex: "/.*\\.(test|spec)?\\.(ts)$", //under test folder, file names should be tests/newTest.test(spec).ts
4+
moduleFileExtensions: ["ts", "js", "json", "node"],
5+
};

logs/access.log

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
::1 - - [08/Sep/2022:04:47:02 +0000] "GET / HTTP/1.1" 304 -
2+
::1 - - [08/Sep/2022:05:03:38 +0000] "GET / HTTP/1.1" 304 -
3+
::1 - - [08/Sep/2022:05:03:40 +0000] "GET / HTTP/1.1" 304 -
4+
::1 - - [08/Sep/2022:05:03:50 +0000] "GET / HTTP/1.1" 304 -
5+
::1 - - [08/Sep/2022:05:03:59 +0000] "GET / HTTP/1.1" 304 -
6+
::1 - - [08/Sep/2022:05:04:00 +0000] "GET / HTTP/1.1" 304 -
7+
::1 - - [08/Sep/2022:05:04:01 +0000] "GET / HTTP/1.1" 304 -
8+
::1 - - [08/Sep/2022:05:04:02 +0000] "GET / HTTP/1.1" 304 -
9+
::1 - - [08/Sep/2022:05:06:36 +0000] "GET / HTTP/1.1" 304 -
10+
::1 - - [08/Sep/2022:05:06:37 +0000] "GET / HTTP/1.1" 304 -
11+
::1 - - [08/Sep/2022:05:06:37 +0000] "GET / HTTP/1.1" 304 -
12+
::1 - - [08/Sep/2022:05:06:37 +0000] "GET / HTTP/1.1" 304 -
13+
::1 - - [08/Sep/2022:05:06:38 +0000] "GET / HTTP/1.1" 304 -
14+
::1 - - [08/Sep/2022:05:06:41 +0000] "GET / HTTP/1.1" 304 -
15+
::1 - - [08/Sep/2022:05:06:42 +0000] "GET / HTTP/1.1" 304 -

0 commit comments

Comments
 (0)