Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converting project to ES module #487

Merged
merged 2 commits into from
Apr 7, 2024
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
HISTORY_ACTIVATED: true
JWT_ADMIN_TOKEN_RENEW_INTERVAL: 5m
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
HISTORY_ACTIVATED: true
JWT_ADMIN_TOKEN_RENEW_INTERVAL: 5m
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
HISTORY_ACTIVATED: true
JWT_ADMIN_TOKEN_RENEW_INTERVAL: 5m
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"]
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019 Roger Floriano (petruki) and Contributors
Copyright (c) 2019-present Roger Floriano (petruki) and Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
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.

30 changes: 16 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,31 @@
"version": "1.2.8",
"description": "Feature Flag/Toggle API",
"main": "start.js",
"type": "module",
"author": {
"name": "Roger Floriano",
"email": "[email protected]"
},
"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",
"pino": "^8.19.0",
"mongoose": "^8.3.0",
"pino": "^8.20.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-admin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { jwt } from '../schemas/admin';
import { pathParameter, queryParameter } from '../schemas/common';
import { commonSchemaContent } from './common';
import { jwt } from '../schemas/admin.js';
import { pathParameter, queryParameter } from '../schemas/common.js';
import { commonSchemaContent } from './common.js';

export default {
'/admin/signup': {
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
4 changes: 2 additions & 2 deletions src/api-docs/paths/path-component.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { pagination, pathParameter, queryParameter } from '../schemas/common';
import { commonArraySchemaContent, commonSchemaContent } from './common';
import { pagination, pathParameter, queryParameter } from '../schemas/common.js';
import { commonArraySchemaContent, commonSchemaContent } from './common.js';

export default {
'/component/create': {
Expand Down
6 changes: 3 additions & 3 deletions src/api-docs/paths/path-config-strategy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { OperationsType, StrategiesType } from '../../models/config-strategy';
import { pagination, pathParameter, queryParameter } from '../schemas/common';
import { commonArraySchemaContent, commonSchemaContent } from './common';
import { OperationsType, StrategiesType } from '../../models/config-strategy.js';
import { pagination, pathParameter, queryParameter } from '../schemas/common.js';
import { commonArraySchemaContent, commonSchemaContent } from './common.js';

export default {
'/configstrategy/create': {
Expand Down
4 changes: 2 additions & 2 deletions src/api-docs/paths/path-config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { pagination, pathParameter, queryParameter } from '../schemas/common';
import { commonArraySchemaContent, commonOneOfSchemaContent, commonSchemaContent } from './common';
import { pagination, pathParameter, queryParameter } from '../schemas/common.js';
import { commonArraySchemaContent, commonOneOfSchemaContent, commonSchemaContent } from './common.js';

export default {
'/config/create': {
Expand Down
Loading