Skip to content

Commit

Permalink
Merge pull request #13 from bcgov/feat/set-up-nest
Browse files Browse the repository at this point in the history
NestJS Setup
  • Loading branch information
hannah-macdonald1 authored Oct 21, 2024
2 parents 8eb2e9c + 495c322 commit 5eb5d26
Show file tree
Hide file tree
Showing 21 changed files with 9,370 additions and 505 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-and-push-ghcr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ env:
HELM_RELEASE_NAME: visitz-api-deployment
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
HUSKY: 0

jobs:

Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# MacOS files
.DS_STORE

# Runtime data
pids
*.pid
Expand Down
6 changes: 6 additions & 0 deletions .husky/install.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Skip Husky install in production and CI
if (process.env.NODE_ENV === 'production' || process.env.CI === 'true') {
process.exit(0)
}
const husky = (await import('husky')).default
console.log(husky())
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
npm run lint
npm run format
npm run test:cov
npm run test:e2e
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ RUN npm install
# Copy the rest of the application files
COPY . .

# Build the application for production
RUN npm run build

# Expose the port your app runs on
EXPOSE 3000

# Command to run the application
CMD ["node", "app.js"]
# Command to run the application in production mode
CMD ["node", "dist/main"]
15 changes: 0 additions & 15 deletions app.js

This file was deleted.

39 changes: 39 additions & 0 deletions docs/ONBOARDING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
## Project setup

Prerequistes:
- Node.js
- npm
- git (for git pre-commit hooks with husky)

To install the project, use

```bash
$ npm install
```
This will install all dependencies, as well as pre-commit hooks for formatting, linting and running tests.

## Compile and run the project

```bash
# development (will not rebuild on change)
$ npm run start

# watch mode (rebuilds on change)
$ npm run start:dev

# production mode
$ npm run start:prod
```

## Run tests

```bash
# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# unit tests with coverage information
$ npm run test:cov
```
52 changes: 52 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import typescriptEslintEslintPlugin from '@typescript-eslint/eslint-plugin';
import globals from 'globals';
import tsParser from '@typescript-eslint/parser';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import js from '@eslint/js';
import { FlatCompat } from '@eslint/eslintrc';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [
{
ignores: ['**/.eslintrc.js', '.husky/install.mjs'],
},
...compat.extends(
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
),
{
plugins: {
'@typescript-eslint': typescriptEslintEslintPlugin,
},

languageOptions: {
globals: {
...globals.node,
...globals.jest,
},

parser: tsParser,
ecmaVersion: 5,
sourceType: 'module',

parserOptions: {
project: 'tsconfig.json',
},
},

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',
},
},
];
8 changes: 8 additions & 0 deletions nest-cli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"deleteOutDir": true
}
}
Loading

0 comments on commit 5eb5d26

Please sign in to comment.