Skip to content

Commit

Permalink
remove unused files
Browse files Browse the repository at this point in the history
  • Loading branch information
reversefuture committed Apr 9, 2024
1 parent 194d7f5 commit dd00d3e
Show file tree
Hide file tree
Showing 60 changed files with 2,126 additions and 428 deletions.
33 changes: 33 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# PORT
PORT = 3000

# DATABASE
DATABASE_URL= mysql://root:123asd@localhost:3306/dev

# TOKEN
# JWT secret key
JWT_SECRET=thisisasamplesecret
# Number of minutes after which an access token expires
JWT_ACCESS_EXPIRATION_MINUTES=30
# Number of days after which a refresh token expires
JWT_REFRESH_EXPIRATION_DAYS=30
# Number of minutes after which a reset password token expires
JWT_RESET_PASSWORD_EXPIRATION_MINUTES=10
# Number of minutes after which a verify email token expires
JWT_VERIFY_EMAIL_EXPIRATION_MINUTES=10

# LOG
LOG_FORMAT = dev
LOG_DIR = ../logs

# CORS
ORIGIN = *
CREDENTIALS = true

# SMTP configuration options for the email service
# For testing, you can use a fake SMTP service like Ethereal: https://ethereal.email/create
SMTP_HOST=email-server
SMTP_PORT=587
SMTP_USERNAME=email-server-username
SMTP_PASSWORD=email-server-password
EMAIL_FROM=[email protected]
4 changes: 3 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/dist
/dist
node_modules
bin
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@typescript-eslint/explicit-module-boundary-types": 0,
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-var-requires": "off"
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-unused-vars": 1
}
}
45 changes: 45 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: CI

on:
pull_request:
push:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'

- name: Install dependencies
run: npm install

- name: Lint
run: npm run lint

- name: Create .env file
run: cp .env.example .env

- name: Start functional tests container
run: docker-compose up -d

- name: Test
run: npm test -- --coverage

- name: Stop functional tests container
if: always()
run: docker-compose -f "docker-compose.yml" down

- name: Publish code coverage to Code Climate
if: ${{ github.ref == 'refs/heads/main' }}
uses: paambaati/[email protected]
env:
CC_TEST_REPORTER_ID: ${{ secrets.CODE_CLIMATE_REPORTER_ID }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ yarn-error.log
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Dependencies
node_modules/
Expand Down
2 changes: 1 addition & 1 deletion .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"*.ts": [
"npm run lint"
"npm run lint:fix"
]
}
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20.10.0
7 changes: 5 additions & 2 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
FROM node:16.18-buster-slim

# Copy Dir
COPY . ./app
COPY . ./app && chown -R node:node /usr/src/node-app

# Work to Dir
WORKDIR /app

# Switch to the node user to perform the following commands as a non-root user
USER node

# Install Node Package
RUN npm install --legacy-peer-deps

Expand All @@ -15,5 +18,5 @@ ENV NODE_ENV development

EXPOSE 3000

# Cmd script
# Cmd script, as the image already started so don't need to run the command in docker-compose.yml
CMD ["npm", "run", "dev"]
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Intro
Template: https://github.com/ljlm0402/typescript-express-starter?tab=readme-ov-file
## nodemon

# nodemon
nodemon is a tool that helps develop Node.js based applications by automatically restarting the node application when file changes in the directory are detected.
>nodemon [your node app]
eg:
Expand Down Expand Up @@ -74,6 +75,3 @@ Makefiles are used to help decide which parts of a large program need to be reco
Modify Makefile file to your source code.



s
43 changes: 43 additions & 0 deletions demo/query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// npx ts-node demo/query.ts
import { PrismaClient } from '@prisma/client';

const prisma = new PrismaClient();

async function main() {
// await prisma.user.create({
// data: {
// name: 'Alice',
// email: '[email protected]',
// posts: {
// create: { title: 'Hello World' },
// },
// profile: {
// create: { bio: 'I like turtles' },
// },
// },
// });

// const allUsers = await prisma.user.findMany({
// include: {
// posts: true,
// profile: true,
// },
// });
// console.dir(allUsers, { depth: null });

const post = await prisma.post.update({
where: { id: 1 },
data: { published: true },
});
console.log(post);
}

main()
.then(async () => {
await prisma.$disconnect();
})
.catch(async e => {
console.error(e);
await prisma.$disconnect();
process.exit(1);
});
68 changes: 0 additions & 68 deletions dev/prisma.md

This file was deleted.

1 change: 1 addition & 0 deletions docker-compose.yml → docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ services:
- mysql
depends_on:
- mysql
# command: npm run dev # The server image is already running npm start in the Dockerfile.dev

mysql:
container_name: mysql
Expand Down
51 changes: 51 additions & 0 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
version: "3.9"

services:
proxy:
container_name: proxy
image: nginx:alpine
ports:
- "80:80"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
restart: "unless-stopped"
networks:
- backend

server:
container_name: server
build:
context: ./
dockerfile: Dockerfile.prod
ports:
- "3000:3000"
environment:
DATABASE_URL: mysql://root:password@localhost:3306/dingding
volumes:
- ./:/app
- /app/node_modules
restart: "unless-stopped"
networks:
- backend
links:
- mysql
depends_on:
- mysql

mysql:
container_name: mysql
image: mysql:5.7
environment:
DATABASE_URL: mysql://root:password@localhost:3306/dingding
ports:
- "3306:3306"
networks:
- backend

networks:
backend:
driver: bridge

volumes:
data:
driver: local
18 changes: 18 additions & 0 deletions docker/Dockerfile.build.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM node:20-alpine AS builder
WORKDIR /app
COPY . .
RUN npm pkg delete scripts.prepare
RUN npm install
RUN npm run build

FROM node:20-alpine
WORKDIR /app
ENV NODE_ENV=production
COPY package*.json ./
COPY --from=builder ./app/prisma ./
COPY --from=builder ./app/dist ./dist
RUN npm pkg delete scripts.prepare
RUN npm ci --only=production --quiet

EXPOSE 3000
CMD ["node", "./dist/server.js"]
15 changes: 15 additions & 0 deletions docker/Dockerfile.chown.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:alpine

RUN mkdir -p /usr/src/node-app && chown -R node:node /usr/src/node-app

WORKDIR /usr/src/node-app

COPY package.json yarn.lock ./

USER node

RUN yarn install --pure-lockfile

COPY --chown=node:node . .

EXPOSE 3000
4 changes: 4 additions & 0 deletions docker/docker-compose-mongodb-redis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,7 @@ volumes:
dbdata:
cache:
driver: local

networks:
node-network:
driver: bridge
12 changes: 12 additions & 0 deletions docker/docker.compose.postgres.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: '3.8'

services:
db:
image: postgres:16-alpine
restart: always
ports:
- '5432:5432'
environment:
POSTGRES_USER: user
POSTGRES_PASSWORD: password
POSTGRES_DB: app
Loading

0 comments on commit dd00d3e

Please sign in to comment.