Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions .gitignore

This file was deleted.

46 changes: 46 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: nexus-api

services:
backend:
build: ./nexus-api
container_name: backend_api
restart: always
ports:
- "3000:3000"
depends_on:
- postgres
environment:
DATABASE_URL: ${DATABASE_URL}
DATABASE_TYPE: ${DATABASE_TYPE}
DATABASE_HOST: ${DATABASE_HOST}
DATABASE_PORT: ${DATABASE_PORT}
DATABASE_USERNAME: ${DATABASE_USERNAME}
DATABASE_PASSWORD: ${DATABASE_PASSWORD}
DATABASE_DATABASE: ${DATABASE_DATABASE}
DATABASE_AUTO_LOAD_ENTITIES: ${DATABASE_AUTO_LOAD_ENTITIES}
DATABASE_SYNCHRONIZE: ${DATABASE_SYNCHRONIZE}
JWT_SECRET: ${JWT_SECRET}
JWT_TOKEN_AUDIENCE: ${JWT_TOKEN_AUDIENCE}
JWT_TOKEN_ISSUER: ${JWT_TOKEN_ISSUER}
JWT_TTL: ${JWT_TTL}
JWT_REFRESH_TTL: ${JWT_REFRESH_TTL}
NODE_ENV: ${NODE_ENV}
PORT: ${PORT}
ORIGIN: ${ORIGIN}

postgres:
image: postgres:17-alpine
container_name: postgres_db
restart: always
environment:
POSTGRES_USER: ${DATABASE_USERNAME}
POSTGRES_PASSWORD: ${DATABASE_PASSWORD}
POSTGRES_DB: ${DATABASE_DATABASE}
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data

volumes:
postgres_data:
driver: local
5 changes: 5 additions & 0 deletions nexus-api/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
dist
.env
.git
.github
22 changes: 22 additions & 0 deletions nexus-api/.env-example
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# DATABASE Configuration
DATABASE_URL=postgresql://$DATABASE_USERNAME:$DATABASE_PASSWORD@localhost:5432/$DATABASE_DATABASE
DATABASE_TYPE=postgres
DATABASE_HOST=localhost
DATABASE_PORT=5432
DATABASE_USERNAME=postgres
DATABASE_PASSWORD=ADD-DATABASE-PASSWORD-HERE
DATABASE_DATABASE=postgres
DATABASE_AUTO_LOAD_ENTITIES=1
DATABASE_SYNCHRONIZE=0

# JWT Configuration
JWT_SECRET=PUT-YOUR-JWT-SECRET
JWT_TOKEN_AUDIENCE=http://localhost:3000
JWT_TOKEN_ISSUER=http://localhost:3000
JWT_TTL=4000
JWT_REFRESH_TTL=86400

# APP Configuration
NODE_ENV=development
PORT=3000
ORIGIN=http://localhost:3000
37 changes: 37 additions & 0 deletions nexus-api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Nestjs specific
/dist
/node_modules
/build
/tmp

# Logs
logs
*.log
npm-debug.log*
pnpm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Tests
/coverage
/.nyc_output

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# dotenv environment variable files
*.env
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# temp directory
.temp
.tmp
4 changes: 4 additions & 0 deletions nexus-api/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}
16 changes: 16 additions & 0 deletions nexus-api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM node:20-alpine AS builder
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm install
COPY . .
RUN npm run build

FROM node:20-alpine AS production
WORKDIR /app
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/package.json ./package.json

EXPOSE 3000

CMD ["node", "dist/main.js"]
37 changes: 37 additions & 0 deletions nexus-api/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// @ts-check
import eslint from '@eslint/js';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import globals from 'globals';
import tseslint from 'typescript-eslint';

export default tseslint.config(
{
ignores: ['eslint.config.mjs'],
},
eslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
// @ts-ignore
eslintPluginPrettierRecommended,
{
languageOptions: {
globals: {
...globals.node,
...globals.jest,
},
ecmaVersion: 5,
sourceType: 'module',
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
{
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-floating-promises': 'warn',
'@typescript-eslint/no-unsafe-argument': 'warn',
'semi': ['error', 'always']
},
},
);
9 changes: 9 additions & 0 deletions nexus-api/nest-cli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"deleteOutDir": true,
"plugins": ["@nestjs/swagger/plugin"]
}
}
Loading