Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env-cmdrc-template
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"test": {
"NODE_OPTIONS": "--experimental-vm-modules",
"ENV": "TEST",
"PORT": "3000",
"SSL_CERT": "",
Expand Down
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"env": {
"node": true,
"commonjs": true,
"commonjs": false,
"es6": true,
"jest": true
},
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
- name: Run tests
run: npm test
env:
NODE_OPTIONS: "--experimental-vm-modules"
MONGODB_URI: mongodb://127.0.0.1:27017/switcher-api-test
JWT_CLIENT_TOKEN_EXP_TIME: 5m
JWT_SECRET: ${{ secrets.JWT_SECRET }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/re-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
- name: Run tests
run: npm test
env:
NODE_OPTIONS: "--experimental-vm-modules"
MONGODB_URI: mongodb://127.0.0.1:27017/switcher-api-test
JWT_CLIENT_TOKEN_EXP_TIME: 5m
JWT_SECRET: ${{ secrets.JWT_SECRET }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
- name: Run tests
run: npm test
env:
NODE_OPTIONS: "--experimental-vm-modules"
MONGODB_URI: mongodb://127.0.0.1:27017/switcher-api-test
JWT_CLIENT_TOKEN_EXP_TIME: 5m
JWT_SECRET: ${{ secrets.JWT_SECRET }}
Expand Down
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ WORKDIR /app
# ---------- Builder ----------
FROM base AS builder

COPY package*.json babel.config.js ./
COPY package*.json ./

RUN npm install

COPY ./src ./src

RUN npm run build && \
npm prune --production
RUN npm prune --production

# ---------- Release ----------
FROM base AS release

COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/build ./dist
COPY --from=builder /app/package*.json ./
COPY --from=builder /app/src ./dist

USER node

CMD ["node", "./dist/index.js"]
CMD ["node", "./dist/start.js"]
12 changes: 0 additions & 12 deletions babel.config.js

This file was deleted.

194 changes: 0 additions & 194 deletions jest.config.js

This file was deleted.

28 changes: 15 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,31 @@
"version": "1.0.0",
"description": "Resolver API to be used with Switcher API",
"main": "start.js",
"type": "module",
"author": {
"name": "Roger Floriano",
"email": "switcher.project@gmail.com"
},
"scripts": {
"build": "npm run clean && npm run build-babel",
"start": "npm run build && node ./build/index.js",
"build-babel": "babel -d ./build ./src -s",
"clean": "rm -rf build && mkdir build",
"start": "node ./src/start.js",
"dev": "env-cmd -e dev nodemon ./src/start.js",
"prod": "env-cmd -e prod nodemon ./src/start.js",
"lint": "eslint src",
"lint": "eslint ./src/**/*.js",
"test": "jest --runInBand --collect-coverage",
"test-local": "env-cmd -e test jest --runInBand --collect-coverage",
"snyk": "snyk test --strict-out-of-sync=false"
},
"jest": {
"transform": {},
"clearMocks": true,
"testEnvironment": "node",
"testResultsProcessor": "jest-sonar-reporter",
"coveragePathIgnorePatterns": [
"<rootDir>/node_modules/",
"<rootDir>/src/api-docs/",
"<rootDir>/src/app-server.js"
]
},
"keywords": [
"feature",
"flag",
Expand All @@ -41,21 +50,14 @@
"jsonwebtoken": "^9.0.2",
"moment": "^2.30.1",
"mongodb": "^6.5.0",
"mongoose": "^8.2.4",
"mongoose": "^8.3.0",
"pino": "^8.19.0",
"pino-pretty": "^11.0.0",
"swagger-ui-express": "^5.0.0",
"switcher-client": "^3.2.1",
"validator": "^13.11.0"
},
"devDependencies": {
"@babel/cli": "^7.24.1",
"@babel/core": "^7.24.3",
"@babel/node": "^7.23.9",
"@babel/preset-env": "^7.24.3",
"@babel/register": "^7.23.7",
"babel-jest": "^29.7.0",
"babel-polyfill": "^6.26.0",
"env-cmd": "^10.1.0",
"eslint": "^8.57.0",
"jest": "^29.7.0",
Expand Down
6 changes: 3 additions & 3 deletions src/api-docs/paths/path-client.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { StrategiesType } from '../../models/config-strategy';
import { pathParameter, queryParameter } from '../schemas/common';
import configStrategy from '../schemas/config-strategy';
import { StrategiesType } from '../../models/config-strategy.js';
import { pathParameter, queryParameter } from '../schemas/common.js';
import configStrategy from '../schemas/config-strategy.js';

export default {
'/criteria': {
Expand Down
2 changes: 1 addition & 1 deletion src/api-docs/schemas/config-strategy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OperationsType, StrategiesType } from '../../models/config-strategy';
import { OperationsType, StrategiesType } from '../../models/config-strategy.js';

const configStrategy = {
type: 'object',
Expand Down
8 changes: 2 additions & 6 deletions src/api-docs/swagger-document.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pathClient from './paths/path-client';
import pathClient from './paths/path-client.js';

import { commonSchema } from './schemas/common';
import info from './swagger-info';
import info from './swagger-info.js';

export default {
openapi: '3.0.1',
Expand All @@ -27,9 +26,6 @@ export default {
in: 'header',
name: 'switcher-api-key'
}
},
schemas: {
...commonSchema
}
},
paths: {
Expand Down
2 changes: 1 addition & 1 deletion src/app-server.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import https from 'https';
import http from 'http';
import fs from 'fs';
import Logger from './helpers/logger';
import Logger from './helpers/logger.js';

export const createServer = (app) => {
if (process.env.SSL_CERT && process.env.SSL_KEY) {
Expand Down
Loading