Skip to content

Commit

Permalink
dev setup
Browse files Browse the repository at this point in the history
  • Loading branch information
killroy192 committed Aug 10, 2024
1 parent be55e1a commit b82394e
Show file tree
Hide file tree
Showing 13 changed files with 1,687 additions and 220 deletions.
18 changes: 18 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Dockerfile
.dockerignore
node_modules
npm-debug.log
README.md
.git
.gitignore
.linterstagedrc.json
jest.config.js
.husky
dist
.vscode
test

conf/.env
conf/.env.keys
conf/.example.secrets.env
conf/.example.env
17 changes: 17 additions & 0 deletions .swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "https://json.schemastore.org/swcrc",
"sourceMaps": true,
"jsc": {
"parser": {
"syntax": "typescript",
"decorators": true,
"dynamicImport": true
},
"transform": {
"legacyDecorator": true,
"decoratorMetadata": true
},
"baseUrl": "./"
},
"minify": false
}
18 changes: 18 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach to API",
"address": "localhost",
"port": 9229,
"localRoot": "${workspaceFolder}",
"remoteRoot": "/app",
"trace": true,
"restart": true,
"sourceMaps": true,
"skipFiles": ["<node_internals>/**"]
}
]
}
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM node:20-alpine as base
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk update && apk add --no-cache libc6-compat
WORKDIR /app
EXPOSE 3000

# Rebuild the source code only when needed
FROM base as deps
RUN apk add --no-cache make && apk add --no-cache bash
COPY . .
RUN npm ci

FROM deps as prod
RUN make build
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 prod-nodejs
USER prod-nodejs
CMD ["make", "start.prod"]

FROM deps as dev
EXPOSE 9229
RUN make build
CMD ["make", "start.debug.open"]
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SHELL := /bin/bash

.PHONY: init build clear lint typecheck test pre-commit pre-push migrate up up-all list funding fuel report profiles recover decrypt encrypt

all: init clean typecheck test
all: init clean typecheck

init:; npm i

Expand All @@ -22,7 +22,7 @@ test.cov :; npx jest --passWithNoTests --coverage

test.debug :; node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand

test.e2e: npx jest --config ./test/jest-e2e.json
test.e2e:; npx jest --config ./test/jest-e2e.json

pre-commit: typecheck lint-stg

Expand All @@ -38,6 +38,8 @@ start.dev:; npx nest start --watch

start.debug:; npx nest start --debug --watch

start.debug.open:; npx nest start --debug 0.0.0.0 --watch

start.prod:; node dist/main

-include ${FCT_PLUGIN_PATH}/makefile-external
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
# web3-glue

Development starter kit for web3 node.js apps with nestjs & viem

## Installation

```bash
npm install
make
```

## Running the app

```bash
# development
$ npm run start
$ make start

# watch mode
$ npm run start:dev
$ make start.dev

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

## Test

```bash
# unit tests
$ npm run test
$ make test

# e2e tests
$ npm run test:e2e
$ make test.e2e

# test coverage
$ npm run test:cov
$ make test.cov
```

## License
Expand Down
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: '3.7'

services:
nest-app-develop:
hostname: nest-app-develop
image: nest-app-develop
restart: always
build:
context: .
target: dev
ports:
- 3000:3000
- 9229:9229
volumes:
- ./src:/app/src:cached
3 changes: 2 additions & 1 deletion nest-cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"deleteOutDir": true
"deleteOutDir": true,
"builder": "swc"
}
}
Loading

0 comments on commit b82394e

Please sign in to comment.