29 Commits

Author SHA1 Message Date
117c78e7a9 Merge pull request 'develop' (#2) from develop into main
Reviewed-on: #2
2023-05-26 16:49:33 +00:00
95ed9bf158 Hehehehe
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-05-26 12:19:35 -04:00
9dc3520989 Finishing touches and version bump... let the development continue!
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-26 12:10:06 -04:00
62c50964fa Yay!
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-26 12:05:46 -04:00
392414354b staging
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-26 11:26:49 -04:00
224eeae092 trying again
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-26 11:23:56 -04:00
64c4345c28 Hmm...
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-26 11:22:24 -04:00
6921bea5b5 Lets try this... kickstart for the db...
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-26 11:06:37 -04:00
ebe086e70f oops
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-26 10:24:49 -04:00
af943c1e84 done test update 2023-05-26 10:22:07 -04:00
50af0b3065 Merge branch 'main' of ssh://git.mifi.dev:12022/mifi/auth-service
# Conflicts:
#	Dockerfile
2023-05-26 10:21:43 -04:00
50e691cf05 Why do I suck at Dockerfiles? 2023-05-26 10:17:36 -04:00
e706ef1924 Why do I suck at Dockerfiles? 2023-05-26 09:35:56 -04:00
0ad99d3f0a Maybe with ENV vars? 2023-05-26 09:13:02 -04:00
bb7b15351d More attempts at publishing... 2023-05-26 09:08:33 -04:00
bc73ab271b ugh 2023-05-25 13:30:17 -04:00
b1b1f3e0b9 Muahahahaha. Or not... 2023-05-25 13:08:14 -04:00
30c86accf6 Hmmm. 2023-05-25 13:00:16 -04:00
0882e8754e Incrementing versions we go... 2023-05-25 12:42:27 -04:00
73ac3d2dc6 Trying this... 2023-05-25 12:33:21 -04:00
5500a5644d Merge pull request 'Restructuring the folders' (#1) from develop into main
Reviewed-on: #1
2023-05-25 16:09:26 +00:00
4f00ef6ae4 Finishing touches?
Some checks failed
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build was killed
2023-05-25 12:06:44 -04:00
6ef8c553ce Cleanup and applied learnings
Some checks failed
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build was killed
2023-05-24 13:07:42 -04:00
f2dce58f5e Tweaks
Some checks failed
continuous-integration/drone/pr Build is failing
continuous-integration/drone/push Build was killed
2023-05-24 10:46:01 -04:00
9c4e47fb72 Oops... paths.
Some checks failed
continuous-integration/drone/pr Build is failing
continuous-integration/drone/push Build was killed
2023-05-24 10:32:19 -04:00
b969adbc2e Restructuring the folders
Some checks failed
continuous-integration/drone/pr Build is failing
continuous-integration/drone/push Build was killed
2023-05-24 10:24:39 -04:00
1fa308b2a9 Fixes 2023-05-23 22:06:09 -04:00
f0c2c8d855 Touch-ups and adding drone pipeline 2023-05-23 15:40:31 -04:00
19b6de68cf Tweaks, fixes, and version bump 2023-05-23 15:04:33 -04:00
42 changed files with 11315 additions and 75 deletions

6
.build.yarnrc.yml Normal file
View File

@@ -0,0 +1,6 @@
nodeLinker: node-modules
npmScopes:
mifi:
npmRegistryServer: https://git.mifi.dev/api/packages/mifi/npm/
npmAuthToken: e35a182b01581790f91996594bc16e5c6a89c71c # ${NPM_TOKEN}
npmAlwaysAuth: true

280
.drone.yml Normal file
View File

@@ -0,0 +1,280 @@
kind: pipeline
type: docker
name: Test Pipeline
workspace:
path: /drone/auth
steps:
- name: yarn install
image: node:20-bullseye-slim
environment:
YARN_VERSION: 3.5.0
commands:
- yarn set version stable
- yarn install
volumes:
- name: yarnrc
path: /drone/auth/.yarnrc.yml
- name: Code Style Checks
image: node:latest
commands:
- yarn prettier
- name: Lint
image: node:latest
commands:
- yarn lint
- name: Unit Tests
image: node:latest
commands:
- yarn test
- name: Send Test Status Notification
image: plugins/webhook
settings:
urls: https://lab.mifi.dev/hooks/9p65zpagctgkmndo8nwwm4199r
content_type: application/json
template: |
{
"icon_url":"https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/apple/198/freezing-face_1f976.png",
"text": "[{{ repo.name }} - Build # {{ build.number }}] Code Quality Checks {{ build.status }} {{#success build.status}}:tada:{{else}}:poop:{{/success}}",
"username":"DroneBot"
}
when:
status:
- success
- failure
- name: Build
image: node:latest
commands:
- yarn build:production
- name: Send Build Status Notifications
image: plugins/webhook
settings:
urls: https://lab.mifi.dev/hooks/9p65zpagctgkmndo8nwwm4199r
content_type: application/json
template: |
{
"icon_url":"https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/apple/198/freezing-face_1f976.png",
"text": "[{{ repo.name }} - Build # {{ build.number }}] Build package {{ build.status }} {{#success build.status}}:tada:{{else}}:poop:{{/success}}",
"username":"DroneBot"
}
when:
status:
- success
- failure
volumes:
- name: yarnrc
host:
path: /volume1/docker/.yarnrc.yml
trigger:
branch:
- main
- develop
event:
- pull_request
---
kind: pipeline
type: docker
name: Publish Pipeline
workspace:
path: /drone/auth
steps:
- name: Build Package
image: node:20-bullseye-slim
environment:
YARN_VERSION: 3.5.0
commands:
- yarn set version stable
- yarn install
- yarn build:package
volumes:
- name: yarnrc
path: /drone/auth/.yarnrc.yml
- name: Publish NPM
image: node:20-bullseye-slim
commands:
- yarn npm publish
volumes:
- name: npmrc
path: /drone/auth/.npmrc
- name: yarnrc
path: /drone/auth/.yarnrc.yml
- name: Report NPM Publish Status
image: plugins/webhook
settings:
urls: https://lab.mifi.dev/hooks/ccw34hdf7tgbjmzp96nptn938r
content_type: application/json
template: |
{
"icon_url":"https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/apple/198/freezing-face_1f976.png",
"text": "[{{ repo.name }} - New npm package release {{tag}} from # {{ build.number }}] Deploy {{ build.status }} {{#success build.status}}:tada:{{else}}:poop:{{/success}}",
"username":"DroneBot"
}
when:
status:
- success
- failure
- name: Publish Image
image: plugins/docker
settings:
auto_tag: true
repo: git.mifi.dev/mifi/auth-service
registry: git.mifi.dev
build_args:
- MONGO_ENTRY_FILE=latest
- MONGO_VERSION=latest
- NPM_TOKEN:
from_secret: reg_token
ssh-agent-key:
from_secret: reg_token
username: <token>
password:
from_secret: reg_token
secrets: [reg_token]
- name: Report Image Publish Status
image: plugins/webhook
settings:
urls: https://lab.mifi.dev/hooks/ccw34hdf7tgbjmzp96nptn938r
content_type: application/json
template: |
{
"icon_url":"https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/apple/198/freezing-face_1f976.png",
"text": "[{{ repo.name }} - New docker image release {{tag}} from # {{ build.number }}] Deploy {{ build.status }} {{#success build.status}}:tada:{{else}}:poop:{{/success}}",
"username":"DroneBot"
}
when:
status:
- success
- failure
volumes:
- name: dockerconfig
host:
path: /volume1/docker/dockerconfig.json
- name: dockersock
host:
path: /var/run/docker.sock
- name: npmrc
host:
path: /volume1/docker/beethoven/labs-auth/.npmrc
- name: yarnrc
host:
path: /volume1/docker/.yarnrc.yml
depends_on:
- Test Pipeline
trigger:
event:
- tag
---
kind: pipeline
type: docker
name: Staging Deploy Pipeline
workspace:
path: /drone/auth
steps:
- name: Deploy Container
image: docker
privileged: true
environment:
CONTAINER_PREFIX: staging
HOST: area51.mifi.dev
ROUTE_PREFIX: /auth
PORT: 9001
commands:
- docker compose -f docker-compose.staging-build.yml build --pull --no-cache
- docker compose -f docker-compose.staging-build.yml up --remove-orphans --force-recreate --wait
volumes:
- name: env-secrets
path: /drone/auth/staging.env
- name: dockersock
path: /var/run/docker.sock
- name: dockerconfig
path: /drone/auth/.docker/config.json
- name: Send Status Notifications
image: plugins/webhook
privileged: true
settings:
urls: https://lab.mifi.dev/hooks/ccw34hdf7tgbjmzp96nptn938r
content_type: application/json
template: |
{
"icon_url":"https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/apple/198/freezing-face_1f976.png",
"text": "[{{ repo.name }} - Build # {{ build.number }}] Staging Deploy {{ build.status }} {{#success build.status}}:tada:{{else}}:poop:{{/success}}",
"username":"DroneBot"
}
when:
status:
- success
- failure
volumes:
- name: dockerconfig
host:
path: /volume1/docker/dockerconfig.json
- name: dockersock
host:
path: /var/run/docker.sock
- name: env-secrets
host:
path: /volume1/docker/beethoven/labs-auth/staging.env
depends_on:
- Test Pipeline
trigger:
branch:
- develop
event:
- push
---
kind: pipeline
type: docker
name: Production Deploy Pipeline
workspace:
path: /drone/auth
clone:
disable: true
steps:
- name: Deploy Container
image: plugins/webhook
settings:
urls: https://portainer.mifi.dev/api/stacks/webhooks/968d2244-2548-4f0b-8c18-bbc9bc35305d
- name: Send Status Notifications
image: plugins/webhook
privileged: true
settings:
urls: https://lab.mifi.dev/hooks/ccw34hdf7tgbjmzp96nptn938r
content_type: application/json
template: |
{
"icon_url":"https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/apple/198/freezing-face_1f976.png",
"text": "[{{ repo.name }} - Build # {{ build.number }}] Production Deploy {{ build.status }} {{#success build.status}}:tada:{{else}}:poop:{{/success}}",
"username":"DroneBot"
}
when:
status:
- success
- failure
depends_on:
- Publish Pipeline
trigger:
event:
- promote
target:
- production

31
.env.dev Normal file
View File

@@ -0,0 +1,31 @@
HOST=localhost
PORT=9001
ROUTE_PREFIX=/auth
LOGIN_ROUTE=/login
RESET_ROUTE=/reset
DB_ADMIN_USERNAME=root
DB_ADMIN_PASSWORD=password
DB_USERNAME=user
DB_PASSWORD=password
DB_NAME=auth
MONGO_INITDB_ROOT_USERNAME=$DB_ADMIN_USERNAME
MONGO_INITDB_ROOT_PASSWORD=$DB_ADMIN_PASSWORD
MONGO_INITDB_DATABASE=$DB_NAME
SESSION_KEY=shjhakjfhfjdshjksdhfdshfhfduyeyb73te4
JWT_AUDIENCE=Grow.io
JWT_ISSUER=Grow Latch
JWT_SECRET=Th!sIs a d3v3lopm3nt server SEcr¢T.
LOGIN_VALID_TIMEOUT=12h
RESET_VALID_TIMEOUT=15m
DEFAULT_TOKEN_DAYS=1
CONTAINER_PREFIX=dev
SERVICE_NAME=auth-service
ENV=development

19
.eslintrc.js Normal file
View File

@@ -0,0 +1,19 @@
/* eslint-env node */
module.exports = {
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/errors',
'plugin:prettier/recommended',
'prettier',
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
settings: {
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
'import/resolver': 'typescript',
},
root: true,
};

3
.gitignore vendored
View File

@@ -130,3 +130,6 @@ dist
.yarn/install-state.gz .yarn/install-state.gz
.pnp.* .pnp.*
# Project
lib/
dist/

12
.npmignore Normal file
View File

@@ -0,0 +1,12 @@
.build.yarnrc.yml
.drone.yml
.env*
.eslintrc*
.npmrc
.prettierrc*
.yarnrc.yml
babel.config.*
jest.config.*
src
tsconfig*.json
tslint.json

3
.npmrc Normal file
View File

@@ -0,0 +1,3 @@
registry=https://registry.npmjs.org
@mifi:registry=https://git.mifi.dev/api/packages/mifi/npm
//git.mifi.dev/api/packages/mifi/npm/:_authToken=${NPM_TOKEN}

7
.prettierrc.js Normal file
View File

@@ -0,0 +1,7 @@
module.exports = {
parser: 'typescript',
printWidth: 120,
trailingComma: 'all',
tabWidth: 4,
singleQuote: true,
};

873
.yarn/releases/yarn-3.5.1.cjs vendored Executable file

File diff suppressed because one or more lines are too long

3
.yarnrc.yml Normal file
View File

@@ -0,0 +1,3 @@
nodeLinker: node-modules
yarnPath: .yarn/releases/yarn-3.5.1.cjs

View File

@@ -1,28 +1,37 @@
ARG ENV=production ARG ENV=production
ARG MONGO_ENTRY_FILE
ARG MONGO_VERSION=latest ARG MONGO_VERSION=latest
ARG NPM_TOKEN
ARG PORT=9001 ARG PORT=9001
ARG YARN_VERSION=3.5.0
## mongo build stage ## mongo build stage
FROM mongo:$MONGO_VERSION AS database FROM mongo:${MONGO_VERSION} AS database
COPY docker-entrypoint-initdb.d/mongo-init-$MONGO_VERSION.sh ./docker-entrypoint-initdb.d/mongo-init.sh ARG MONGO_ENTRY_FILE=${MONGO_ENTRY_FILE:-latest}
COPY docker-entrypoint-initdb.d/mongo-init-${MONGO_ENTRY_FILE}.sh ./docker-entrypoint-initdb.d/mongo-init.sh
## stage one, build the service ## stage one, build the service
FROM node:20-alpine AS build FROM node:20-bullseye-slim AS build
ENV NODE_ENV development ENV YARN_VERSION=${YARN_VERSION}
ENV NODE_ENV=development
ENV NPM_TOKEN=${NPM_TOKEN}
WORKDIR /home/node/app WORKDIR /home/node/app
COPY package*.json ./ COPY .npmrc /root
COPY tsconfig.json ./ COPY .build.yarnrc.yml /root/.yarnrc.yml
COPY lib ./lib COPY . .
RUN ls -a RUN yarn set version stable && yarn install
RUN yarn install RUN yarn build:production
RUN yarn build
## this is stage two , where the app actually runs ## this is stage two , where the app actually runs
FROM node:20-alpine AS containerize FROM node:20-bullseye-slim AS containerize
ENV NODE_ENV $ENV ENV YARN_VERSION=${YARN_VERSION}
ENV NODE_ENV=${ENV}
ENV NPM_TOKEN=${NPM_TOKEN}
WORKDIR /home/node/app WORKDIR /home/node/app
COPY package*.json ./ COPY .npmrc /root
RUN yarn install --frozen-lockfile --production COPY .build.yarnrc.yml /root/.yarnrc.yml
COPY --from=build /home/node/app/dist . COPY package*.json yarn.lock ./
RUN yarn set version stable && yarn install && yarn cache clean
COPY --from=build /home/node/app/dist ./
EXPOSE $PORT EXPOSE $PORT
CMD ["node","server/index.js"] CMD ["node","index.js"]

View File

@@ -1,6 +1 @@
module.exports = { export const presets = [['@babel/preset-env', { targets: { node: 'current' } }], '@babel/preset-typescript'];
presets: [
['@babel/preset-env', { targets: { node: 'current' } }],
'@babel/preset-typescript',
],
};

View File

@@ -8,7 +8,7 @@ services:
context: . context: .
target: database target: database
args: args:
MONGO_VERSION: 6.0.5 MONGO_VERSION: latest
ports: ports:
- 27017:27017 - 27017:27017
networks: networks:
@@ -17,7 +17,7 @@ services:
- auth-db:/data/db - auth-db:/data/db
- auth-db:/data/configdb - auth-db:/data/configdb
restart: unless-stopped restart: unless-stopped
image: mongo:latest image: ${CONTAINER_PREFIX}-auth-service_mongo:${TAG:-latest}
auth-service: auth-service:
env_file: .env.dev env_file: .env.dev
build: build:
@@ -26,6 +26,8 @@ services:
args: args:
- PORT - PORT
- ENV - ENV
- NPM_TOKEN
- YARN_VERSION=3.5.0
container_name: ${CONTAINER_PREFIX}-auth-service container_name: ${CONTAINER_PREFIX}-auth-service
ports: ports:
- 9001:9001 - 9001:9001
@@ -35,7 +37,7 @@ services:
- labs-net - labs-net
- backend - backend
restart: unless-stopped restart: unless-stopped
image: node:20-alpine image: ${CONTAINER_PREFIX}-auth-service:${TAG:-latest}
depends_on: depends_on:
- auth-service_mongo - auth-service_mongo
networks: networks:

View File

@@ -9,14 +9,15 @@ services:
context: . context: .
target: database target: database
args: args:
MONGO_VERSION: 4.4 - MONGO_ENTRY_FILE=4.4
- MONGO_VERSION=4.4
networks: networks:
- auth-backend - auth-backend
volumes: volumes:
- 'auth-db:/data/db' - 'auth-db:/data/db'
- 'auth-db:/data/configdb' - 'auth-db:/data/configdb'
restart: unless-stopped restart: unless-stopped
image: mongo:4.4 image: ${CONTAINER_PREFIX}auth-service_mongo:${DRONE_TAG:-latest}
auth-service: auth-service:
container_name: ${CONTAINER_PREFIX}-auth-service container_name: ${CONTAINER_PREFIX}-auth-service
env_file: env_file:
@@ -42,7 +43,7 @@ services:
- auth-backend - auth-backend
- docknet - docknet
restart: unless-stopped restart: unless-stopped
image: node:20-alpine image: ${CONTAINER_PREFIX}auth-service:${DRONE_TAG:-latest}
depends_on: depends_on:
- auth-service_mongo - auth-service_mongo
networks: networks:
@@ -55,4 +56,4 @@ networks:
volumes: volumes:
auth-db: auth-db:
external: false external: true

View File

@@ -3,41 +3,57 @@ version: '3.8'
services: services:
auth-service_mongo: auth-service_mongo:
container_name: ${CONTAINER_PREFIX}-auth-service_mongo container_name: ${CONTAINER_PREFIX}-auth-service_mongo
env_file:
- staging.env
networks: networks:
- auth-backend
- docknet - docknet
volumes: volumes:
- auth-db:/data - auth-db:/data/db
- ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro - auth-db:/data/configdb
restart: unless-stopped restart: unless-stopped
image: mongo:4.4 image: mongo:${MONGO_VERSION}
auth-service: auth-service:
env_file:
- staging.env
container_name: ${CONTAINER_PREFIX}-auth-service container_name: ${CONTAINER_PREFIX}-auth-service
environment: environment:
- DB_HOST=${CONTAINER_PREFIX}-auth-service_mongo - DB_HOST=${CONTAINER_PREFIX}-auth-service_mongo
- DB_NAME=${DB_NAME}
- DB_PASSWORD=${DB_PASSWORD}
- DB_USERNAME=${DB_USERNAME}
- DEFAULT_TOKEN_DAYS=${DEFAULT_TOKEN_DAYS}
- JWT_AUDIENCE=${JWT_AUDIENCE}
- JWT_ISSUER=${JWT_ISSUER}
- JWT_SECRET=${JWT_SECRET}
- LOGIN_ROUTE=${LOGIN_ROUTE}
- LOGIN_VALID_TIME=${LOGIN_VALID_TIME}
- PORT=${PORT}
- RESET_ROUTE=${RESET_ROUTE}
- RESET_VALID_MINUTES=${RESET_VALID_MINUTES}
- ROUTE_PREFIX=${ROUTE_PREFIX}
- SESSION_KEY=${SESSION_KEY}
labels: labels:
- 'traefik.enable=true' - 'traefik.enable=true'
- 'traefik.http.routers.grow.rule=Host(`${HOST}`) && Path(`${ROUTE_PREFIX}`)' - 'traefik.docker.network=docknet'
- 'traefik.http.routers.grow.entrypoints=websecure' - 'traefik.http.routers.auth.rule=Host(`${HOST}`) && PathPrefix(`${ROUTE_PREFIX}`)'
- 'traefik.http.routers.grow.tls=true' - 'traefik.http.routers.auth.entrypoints=websecure'
- 'traefik.http.routers.grow.tls.certresolver=letsencrypt' - 'traefik.http.routers.auth.tls=true'
- 'traefik.http.routers.grow.service=grow-service' - 'traefik.http.routers.auth.tls.certresolver=letsencrypt'
- 'traefik.http.services.grow-service.loadbalancer.server.port=${PORT}' - 'traefik.http.routers.auth.service=auth-service'
- 'traefik.http.services.auth-service.loadbalancer.server.port=${PORT}'
networks: networks:
- auth-backend
- docknet - docknet
restart: unless-stopped restart: unless-stopped
depends_on: depends_on:
- auth-service_mongo - auth-service_mongo
image: git.mifi.dev/mifi/mifi/auth:latest image: git.mifi.dev/mifi/auth-service:latest
networks: networks:
auth-backend:
driver: bridge
external: false
docknet: docknet:
name: docknet name: docknet
external: true external: true
volumes: volumes:
auth-db: auth-db:
external: false external: true

View File

@@ -1,17 +1,19 @@
{ {
"name": "@mifi/auth-service", "name": "@mifi/auth-service",
"version": "1.0.0", "version": "1.0.12",
"author": "mifi (Mike Fitzpatrick)", "author": "mifi (Mike Fitzpatrick)",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"build": "tsc", "build": "tsc",
"build:production": "tsc -p .", "build:package": "tsc -p ./tsconfig.package.json",
"build:production": "tsc -p ./tsconfig.production.json",
"format": "prettier:fix && lint:fix", "format": "prettier:fix && lint:fix",
"lint": "eslint --ext .ts,.tsx lib/", "lint": "eslint --ext .ts,.tsx src/",
"lint:fix": "eslint --fix --ext .ts,.tsx lib/", "lint:fix": "eslint --fix --ext .ts,.tsx src/",
"prettier": "prettier --check 'lib/**/*.ts'", "prettier": "prettier --check 'src/**/*.ts'",
"prettier:fix": "prettier --write 'lib/**/*.ts'", "prettier:fix": "prettier --write 'src/**/*.ts'",
"serve": "node dist/lib/index.js", "serve-dev": "ts-node src/index.ts",
"serve": "node lib/index.js",
"start": "nodemon", "start": "nodemon",
"test": "jest --passWithNoTests" "test": "jest --passWithNoTests"
}, },
@@ -19,7 +21,7 @@
"@babel/core": "^7.21.8", "@babel/core": "^7.21.8",
"@babel/preset-env": "^7.21.5", "@babel/preset-env": "^7.21.5",
"@babel/preset-typescript": "^7.21.5", "@babel/preset-typescript": "^7.21.5",
"@tsconfig/node16": "^1.0.3", "@tsconfig/node16": "^1.0.4",
"@types/jest": "^29.5.1", "@types/jest": "^29.5.1",
"@types/jsonwebtoken": "^9.0.1", "@types/jsonwebtoken": "^9.0.1",
"@types/koa": "^2.13.5", "@types/koa": "^2.13.5",
@@ -56,7 +58,8 @@
"typescript": "^4.9.5" "typescript": "^4.9.5"
}, },
"dependencies": { "dependencies": {
"@mifi/auth-db": "^1.0.0", "@mifi/auth-db": "^1.x.x",
"@mifi/services-common": "^1.x.x",
"@simplewebauthn/server": "^7.2.0", "@simplewebauthn/server": "^7.2.0",
"dotenv": "^16.0.3", "dotenv": "^16.0.3",
"http-status-codes": "^2.2.0", "http-status-codes": "^2.2.0",
@@ -79,6 +82,7 @@
"description": "", "description": "",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://git.mifi.dev/mifi/auth-api.git" "url": "https://git.mifi.dev/mifi/auth-service.git"
} },
"packageManager": "yarn@3.5.1"
} }

View File

@@ -7,7 +7,7 @@ import passport from './passport';
import { performanceLogger, performanceTimer } from './middleware/performance'; import { performanceLogger, performanceTimer } from './middleware/performance';
import { errorHandler } from './middleware/errorHandler'; import { errorHandler } from './middleware/errorHandler';
import { authRouter } from './controllers/auth'; import { authRouter } from './controllers/auth';
import { SESSION_KEY } from '../constants/env'; import { SESSION_KEY } from './constants/env';
const app: Koa = new Koa(); const app: Koa = new Koa();

View File

@@ -3,13 +3,13 @@ import Koa from 'koa';
import Router from 'koa-router'; import Router from 'koa-router';
import { StringSchemaDefinition } from 'mongoose'; import { StringSchemaDefinition } from 'mongoose';
import { Auth } from '@mifi/services-common/lib/db'; import { Auth } from '@mifi/auth-db/lib';
import { create } from '@mifi/services-common/lib/db/dao/create'; import { deleteStrategy } from '@mifi/auth-db/lib/api/deleteStrategy';
import { resetPasswordPost } from '@mifi/services-common/lib/db/api/resetPasswordPost'; import { resetPasswordGet } from '@mifi/auth-db/lib/api/resetPasswordGet';
import { resetPasswordGet } from '@mifi/services-common/lib/db/api/resetPasswordGet'; import { resetPasswordPost } from '@mifi/auth-db/lib/api/resetPasswordPost';
import { deleteById } from '@mifi/services-common/lib/db/dao/deleteById'; import { create } from '@mifi/auth-db/lib/dao/create';
import { deleteStrategy } from '@mifi/services-common/lib/db/api/deleteStrategy'; import { deleteById } from '@mifi/auth-db/lib/dao/deleteById';
import { AuthDocument } from '@mifi/services-common/lib/db/schema/auth'; import { AuthDocument } from '@mifi/auth-db/lib/schema/auth';
import { ROUTE_PREFIX as prefix, RESET_ROUTE } from '../constants/env'; import { ROUTE_PREFIX as prefix, RESET_ROUTE } from '../constants/env';
import passport from '../passport'; import passport from '../passport';

View File

@@ -1,6 +1,6 @@
import app from './app'; import app from './app';
import { connection } from '../db'; import { connection } from '@mifi/auth-db/lib';
import { PORT } from '../constants/env'; import { PORT } from './constants/env';
connection.then( connection.then(
() => { () => {

View File

@@ -4,6 +4,7 @@ import { Context, Next } from 'koa';
export const errorHandler = async (ctx: Context, next: Next) => { export const errorHandler = async (ctx: Context, next: Next) => {
try { try {
await next(); await next();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) { } catch (error: any) {
ctx.status = error.statusCode || error.status || StatusCodes.INTERNAL_SERVER_ERROR; ctx.status = error.statusCode || error.status || StatusCodes.INTERNAL_SERVER_ERROR;
error.status = ctx.status; error.status = ctx.status;

View File

@@ -1,9 +1,9 @@
import passport from 'koa-passport'; import passport from 'koa-passport';
import { Types } from 'mongoose'; import { Types } from 'mongoose';
import { AuthDocument } from '@mifi/services-common/lib/db/schema/auth'; import { AuthDocument } from '@mifi/auth-db/lib/schema/auth';
import { readOneByRecord } from '@mifi/services-common/lib/db/dao/readOneByRecord'; import { readOneByRecord } from '@mifi/auth-db/lib/dao/readOneByRecord';
import { readOneById } from '@mifi/services-common/lib/db/dao/readOneById'; import { readOneById } from '@mifi/auth-db/lib/dao/readOneById';
import LocalStrategy from './strategies/local'; import LocalStrategy from './strategies/local';
import JwtStrategy from './strategies/jwt'; import JwtStrategy from './strategies/jwt';

View File

@@ -1,6 +1,6 @@
import { ExtractJwt, Strategy as JwtStrategy } from 'passport-jwt'; import { ExtractJwt, Strategy as JwtStrategy } from 'passport-jwt';
import { readOneByRecord } from '@mifi/services-common/lib/db/dao/readOneByRecord'; import { readOneByRecord } from '@mifi/auth-db/lib/dao/readOneByRecord';
import { JWT_SECRET } from '../../constants/env'; import { JWT_SECRET } from '../../constants/env';

View File

@@ -1,9 +1,9 @@
// eslint-disable-next-line import/named // eslint-disable-next-line import/named
import { Strategy as LocalStrategy } from 'passport-local'; import { Strategy as LocalStrategy } from 'passport-local';
import { authenticate } from '@mifi/services-common/lib/db/api/authenticate'; import { authenticate } from '@mifi/auth-db/lib/api/authenticate';
export default new LocalStrategy(async (username: string, password: string, done: any) => { export default new LocalStrategy(async (username, password, done) => {
const user = await authenticate(username, password); const user = await authenticate(username, password);
done(null, user); done(null, user);
}); });

View File

@@ -2,11 +2,16 @@
"extends": "@tsconfig/node16/tsconfig.json", "extends": "@tsconfig/node16/tsconfig.json",
"compilerOptions": { "compilerOptions": {
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,
"declaration": true,
"experimentalDecorators": true, "experimentalDecorators": true,
"emitDecoratorMetadata": true, "emitDecoratorMetadata": true,
"noImplicitAny": true, "noImplicitAny": true,
"outDir": "./dist/", "outDir": "dist/",
"rootDirs": ["lib"], "rootDirs": ["./", "src/"],
"sourceMap": true "strict": true,
} "esModuleInterop": true,
"sourceMap": true,
"removeComments": false
},
"include": ["src"]
} }

17
tsconfig.package.json Normal file
View File

@@ -0,0 +1,17 @@
{
"extends": "@tsconfig/node16/tsconfig.json",
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"declaration": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noImplicitAny": true,
"outDir": "dist/",
"rootDirs": ["./", "src/"],
"strict": true,
"esModuleInterop": true,
"sourceMap": false,
"removeComments": true
},
"include": ["./src"]
}

17
tsconfig.production.json Normal file
View File

@@ -0,0 +1,17 @@
{
"extends": "@tsconfig/node16/tsconfig.json",
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"declaration": false,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noImplicitAny": true,
"outDir": "dist/",
"rootDirs": ["./", "src/"],
"strict": true,
"esModuleInterop": true,
"sourceMap": false,
"removeComments": true
},
"include": ["./src"]
}

9936
yarn.lock Normal file

File diff suppressed because it is too large Load Diff