-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 307894b
Showing
69 changed files
with
8,244 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
docker-compose.env | ||
docker-compose.yml | ||
Dockerfile | ||
node_modules | ||
test | ||
.vscode | ||
.git | ||
.github | ||
.env.example | ||
*.md | ||
.env | ||
!README*.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
DATABASE_URL=mongodb://dev:dev@localhost:27017/ | ||
TOKEN_SECRET=TOKEN_SECRET | ||
CLOUDINARY_NAME=CLOUDINARY_NAME | ||
CLOUDINARY_KEY=CLOUDINARY_KEY | ||
CLOUDINARY_SECRET=CLOUDINARY_SECRET | ||
JWT_SECRET=JWT_SECRET |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module.exports = { | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
project: 'tsconfig.json', | ||
tsconfigRootDir: __dirname, | ||
sourceType: 'module', | ||
}, | ||
plugins: ['@typescript-eslint/eslint-plugin'], | ||
extends: [ | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:prettier/recommended', | ||
], | ||
root: true, | ||
env: { | ||
node: true, | ||
jest: true, | ||
}, | ||
ignorePatterns: ['.eslintrc.js'], | ||
rules: { | ||
'@typescript-eslint/interface-name-prefix': 'off', | ||
'@typescript-eslint/explicit-function-return-type': 'off', | ||
'@typescript-eslint/explicit-module-boundary-types': 'off', | ||
'@typescript-eslint/no-explicit-any': 'off', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Continuous integration | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
|
||
permissions: { } | ||
|
||
jobs: | ||
validate-docker-build: | ||
name: Validate if docker image builds | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
permissions: | ||
contents: read | ||
packages: read | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Build & tag docker image | ||
uses: AplinkosMinisterija/reusable-workflows/.github/actions/docker-build-tag-push@main | ||
with: | ||
environment: test | ||
push: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Deploy to Development | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
deploy-development: | ||
name: Deploy development | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build & tag docker image | ||
uses: AplinkosMinisterija/reusable-workflows/.github/actions/docker-build-tag-push@main | ||
with: | ||
environment: development | ||
push: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# compiled output | ||
/dist | ||
/node_modules | ||
|
||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
pnpm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
# OS | ||
.DS_Store | ||
|
||
# Tests | ||
/coverage | ||
/.nyc_output | ||
|
||
# IDEs and editors | ||
/.idea | ||
.project | ||
.classpath | ||
.c9/ | ||
*.launch | ||
.settings/ | ||
*.sublime-workspace | ||
|
||
# IDE - VSCode | ||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json | ||
|
||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
yarn lint-staged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v20.8.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"singleQuote": true, | ||
"trailingComma": "all" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Stage 1: Base image | ||
FROM node:20-alpine as base | ||
|
||
# Stage 2: Builder image | ||
FROM base as builder | ||
|
||
# Set the working directory | ||
WORKDIR /app | ||
|
||
# Install dependencies | ||
COPY package.json yarn.lock ./ | ||
RUN yarn install --immutable --immutable-cache --inline-builds --production=false | ||
|
||
# Copy source | ||
COPY . . | ||
|
||
# Build the application | ||
RUN yarn build | ||
|
||
# Stage 3: Final production image | ||
FROM base | ||
|
||
# Set the working directory | ||
WORKDIR /app | ||
|
||
# Install only production dependencies | ||
COPY package.json yarn.lock ./ | ||
RUN yarn install --immutable --immutable-cache --inline-builds --production \ | ||
&& yarn cache clean | ||
|
||
# Copy built artifacts from builder stage | ||
COPY --from=builder /app/dist/ ./dist/ | ||
|
||
# Docker build args and environment variables | ||
ARG VERSION | ||
ENV VERSION=${VERSION} | ||
|
||
ARG ENVIRONMENT | ||
ENV ENVIRONMENT=${ENVIRONMENT} | ||
|
||
ENV NODE_ENV=production | ||
ENV TZ=Etc/GMT | ||
|
||
# Expose application port | ||
EXPOSE 3000 | ||
|
||
# Start the server | ||
CMD ["sh", "-c", "yarn start:prod"] | ||
|
||
# Healthcheck | ||
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 CMD wget -qO- http://localhost:3000/healthcheck || exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Tvarkau Lietuvą API | ||
|
||
|
||
## Getting Started | ||
|
||
### Installation | ||
|
||
1. Clone the repository: | ||
|
||
```bash | ||
git clone https://github.com/AplinkosMinisterija/tvarkau-lietuva-api.git | ||
``` | ||
|
||
2. Install the required dependencies: | ||
|
||
```bash | ||
cd tvarkau-lietuva-api | ||
yarn install | ||
``` | ||
|
||
### Usage | ||
|
||
1. Set up the required environment variables. Copy the `.env.example` file to `.env` and provide the necessary values | ||
for the variables. | ||
|
||
2. Start the API server: | ||
|
||
```bash | ||
yarn dc:up | ||
yarn start:debug | ||
``` | ||
|
||
The API will be available at `http://localhost:3000`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
version: "3.9" | ||
|
||
services: | ||
mongo: | ||
image: mongo:7 | ||
restart: always | ||
ports: | ||
- "27017:27017" | ||
environment: | ||
MONGO_INITDB_ROOT_USERNAME: dev | ||
MONGO_INITDB_ROOT_PASSWORD: dev | ||
|
||
mongo-express: | ||
image: mongo-express:1 | ||
restart: always | ||
ports: | ||
- "8081:8081" | ||
environment: | ||
ME_CONFIG_MONGODB_ADMINUSERNAME: dev | ||
ME_CONFIG_MONGODB_ADMINPASSWORD: dev | ||
ME_CONFIG_MONGODB_URL: mongodb://dev:dev@mongo:27017/ | ||
|
||
api: | ||
build: . | ||
restart: always | ||
ports: | ||
- "3000:3000" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/nest-cli", | ||
"collection": "@nestjs/schematics", | ||
"sourceRoot": "src", | ||
"compilerOptions": { | ||
"deleteOutDir": true, | ||
"plugins": [ | ||
"@nestjs/swagger" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
{ | ||
"name": "tvarkau-lietuva-backend", | ||
"version": "0.0.1", | ||
"description": "", | ||
"author": "", | ||
"private": true, | ||
"license": "UNLICENSED", | ||
"scripts": { | ||
"build": "nest build", | ||
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", | ||
"start": "nest start", | ||
"start:dev": "nest start --watch", | ||
"start:debug": "nest start --debug --watch", | ||
"start:prod": "node dist/main", | ||
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\"", | ||
"lint:fix": "yarn lint --fix", | ||
"test": "jest", | ||
"dc:up": "docker compose -p tvarkau-lietuva-api up --build -d", | ||
"dc:down": "docker compose -p tvarkau-lietuva-api down", | ||
"test:watch": "jest --watch", | ||
"test:cov": "jest --coverage", | ||
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", | ||
"test:e2e": "jest --config ./test/jest-e2e.json", | ||
"prepare": "husky install" | ||
}, | ||
"engines": { | ||
"node": "20.x" | ||
}, | ||
"dependencies": { | ||
"@nestjs/axios": "^3.0.1", | ||
"@nestjs/common": "^10.0.0", | ||
"@nestjs/config": "^3.1.1", | ||
"@nestjs/core": "^10.0.0", | ||
"@nestjs/jwt": "^10.2.0", | ||
"@nestjs/mongoose": "^10.0.1", | ||
"@nestjs/passport": "^10.0.2", | ||
"@nestjs/platform-express": "^10.0.0", | ||
"@nestjs/swagger": "^7.1.13", | ||
"@types/buffer-to-stream": "^1.0.3", | ||
"@types/passport": "^1.0.16", | ||
"@types/passport-jwt": "^3.0.13", | ||
"@types/passport-local": "^1.0.38", | ||
"axios": "^1.6.2", | ||
"bcrypt": "^5.1.1", | ||
"buffer-to-stream": "^1.0.0", | ||
"class-transformer": "^0.5.1", | ||
"class-validator": "^0.14.0", | ||
"cloudinary": "^1.41.0", | ||
"jsonwebtoken": "^9.0.2", | ||
"mongoose": "^7.6.1", | ||
"multer": "^1.4.5-lts.1", | ||
"passport": "^0.7.0", | ||
"passport-jwt": "^4.0.1", | ||
"passport-local": "^1.0.0", | ||
"reflect-metadata": "^0.1.13", | ||
"rxjs": "^7.8.1" | ||
}, | ||
"devDependencies": { | ||
"@nestjs/cli": "^10.0.0", | ||
"@nestjs/schematics": "^10.0.0", | ||
"@nestjs/testing": "^10.0.0", | ||
"@types/express": "^4.17.17", | ||
"@types/jest": "^29.5.2", | ||
"@types/multer": "^1.4.10", | ||
"@types/node": "^20.3.1", | ||
"@types/supertest": "^2.0.12", | ||
"@typescript-eslint/eslint-plugin": "^6.0.0", | ||
"@typescript-eslint/parser": "^6.0.0", | ||
"eslint": "^8.42.0", | ||
"eslint-config-prettier": "^9.0.0", | ||
"eslint-plugin-prettier": "^5.0.0", | ||
"husky": "^8.0.3", | ||
"jest": "^29.5.0", | ||
"lint-staged": "^15.2.0", | ||
"prettier": "^3.0.0", | ||
"source-map-support": "^0.5.21", | ||
"supertest": "^6.3.3", | ||
"ts-jest": "^29.1.0", | ||
"ts-loader": "^9.4.3", | ||
"ts-node": "^10.9.1", | ||
"tsconfig-paths": "^4.2.0", | ||
"typescript": "^5.1.3" | ||
}, | ||
"lint-staged": { | ||
"*.{js,jsx,ts,tsx}": [ | ||
"prettier --write", | ||
"eslint" | ||
], | ||
"*.{md,html,css,yml}": "prettier --write" | ||
}, | ||
"jest": { | ||
"moduleFileExtensions": [ | ||
"js", | ||
"json", | ||
"ts" | ||
], | ||
"rootDir": "src", | ||
"testRegex": ".*\\.spec\\.ts$", | ||
"transform": { | ||
"^.+\\.(t|j)s$": "ts-jest" | ||
}, | ||
"collectCoverageFrom": [ | ||
"**/*.(t|j)s" | ||
], | ||
"coverageDirectory": "../coverage", | ||
"testEnvironment": "node" | ||
} | ||
} |
Oops, something went wrong.