Skip to content

Commit

Permalink
build: Run NPM format and fix release config (#246)
Browse files Browse the repository at this point in the history
* Add prettier config

* Update dependabot.yml

* npm update

* Release config

* npm run format
  • Loading branch information
ankurdotb authored Oct 31, 2023
1 parent 5931dc2 commit dbc1d4a
Show file tree
Hide file tree
Showing 19 changed files with 1,058 additions and 1,003 deletions.
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ updates:
directory: "/"
schedule:
interval: "weekly"
ignore:
- dependency-name: "*"
update-types:
- version-update:semver-patch

# Maintain dependencies for Docker
- package-ecosystem: "docker"
Expand Down
21 changes: 0 additions & 21 deletions .github/linters/.commitlint.rules.js

This file was deleted.

11 changes: 11 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.DS_Store
node_modules
/dist

# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock
*.md
*.yaml
*.yml
9 changes: 9 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"useTabs": true,
"tabWidth": 4,
"printWidth": 120,
"proseWrap": "always",
"semi": true,
"singleQuote": true,
"trailingComma": "es5"
}
1 change: 0 additions & 1 deletion .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
[
"@semantic-release/commit-analyzer",
{
"parserOpts": "./.github/linters/.commitlint.rules.js",
"releaseRules": [
{ "breaking": true, "release": "major" },
{ "type": "feat", "release": "minor" },
Expand Down
72 changes: 31 additions & 41 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"scripts": {
"dev": "nodemon src/index.ts",
"start": "node dist/index.js",
"build": "esbuild src/index.ts --platform=node --bundle --minify --outdir=dist --external:swagger-ui-express"
"build": "esbuild src/index.ts --platform=node --bundle --minify --outdir=dist --external:swagger-ui-express",
"format": "prettier --write 'src/**/*.{js,ts,cjs,mjs}' 'tests/**/*.{js,ts,cjs,mjs}'"
},
"files": [
"dist",
Expand Down Expand Up @@ -45,8 +46,8 @@
"@semantic-release/release-notes-generator": "^12.0.0",
"@types/express": "^4.17.20",
"@types/helmet": "^4.0.0",
"@types/node": "^20.8.9",
"@types/node-fetch": "^2.6.7",
"@types/node": "^20.8.10",
"@types/node-fetch": "^2.6.8",
"@types/swagger-ui-express": "^4.1.5",
"@types/uuid": "^9.0.6",
"@typescript-eslint/eslint-plugin": "^5.62.0",
Expand All @@ -57,11 +58,14 @@
"eslint-config-prettier": "^8.10.0",
"eslint-config-typescript": "^3.0.0",
"prettier": "^3.0.3",
"semantic-release": "^22.0.5",
"semantic-release": "^22.0.6",
"typescript": "^5.2.2"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/",
"access": "public"
},
"engines": {
"node": ">=18.0.0"
}
}
109 changes: 64 additions & 45 deletions src/app.ts
Original file line number Diff line number Diff line change
@@ -1,50 +1,69 @@
import express from 'express'
import Helmet from 'helmet'
import * as swagger from 'swagger-ui-express'
import * as swaggerJson from '../swagger.json'
import express from 'express';
import Helmet from 'helmet';
import * as swagger from 'swagger-ui-express';
import * as swaggerJson from '../swagger.json';

import { DidController } from './controllers/did'
import { CheqdController } from './controllers/cheqd'
import { ResourceController } from './controllers/resource'
import { CheqdRegistrar } from './service/cheqd'
import { DidController } from './controllers/did';
import { CheqdController } from './controllers/cheqd';
import { ResourceController } from './controllers/resource';
import { CheqdRegistrar } from './service/cheqd';

class App {
public express: express.Application

constructor() {
this.express = express()
this.middleware()
this.routes()
CheqdRegistrar.instance
}

private middleware() {
this.express.use(express.json({ limit: '50mb' }))
this.express.use(express.urlencoded({ extended: false }))
this.express.use(Helmet())
this.express.use('/api-docs', swagger.serve, swagger.setup(swaggerJson))
}

private routes() {
const app = this.express
const URL_PREFIX = '/1.0'

app.get('/', (req, res) => res.redirect('api-docs'))

// did-registrar
app.post(`${URL_PREFIX}/create`, DidController.createValidator, DidController.commonValidator, new DidController().create)
app.post(`${URL_PREFIX}/update`, DidController.updateValidator, DidController.commonValidator, new DidController().update)
app.post(`${URL_PREFIX}/deactivate`, DidController.deactivateValidator, DidController.commonValidator, new DidController().deactivate)
app.post(`${URL_PREFIX}/:did/create-resource`, ResourceController.createValidator, DidController.commonValidator, new ResourceController().create)

// cheqd-helpers
app.get(`${URL_PREFIX}/key-pair`, new CheqdController().generateKeys)
app.get(`${URL_PREFIX}/did-document`, CheqdController.didDocValidator, new CheqdController().generateDidDoc)

// 404 for all other requests
app.all('*', (req, res) => res.status(400).send('Bad request'))
}

public express: express.Application;

constructor() {
this.express = express();
this.middleware();
this.routes();
CheqdRegistrar.instance;
}

private middleware() {
this.express.use(express.json({ limit: '50mb' }));
this.express.use(express.urlencoded({ extended: false }));
this.express.use(Helmet());
this.express.use('/api-docs', swagger.serve, swagger.setup(swaggerJson));
}

private routes() {
const app = this.express;
const URL_PREFIX = '/1.0';

app.get('/', (req, res) => res.redirect('api-docs'));

// did-registrar
app.post(
`${URL_PREFIX}/create`,
DidController.createValidator,
DidController.commonValidator,
new DidController().create
);
app.post(
`${URL_PREFIX}/update`,
DidController.updateValidator,
DidController.commonValidator,
new DidController().update
);
app.post(
`${URL_PREFIX}/deactivate`,
DidController.deactivateValidator,
DidController.commonValidator,
new DidController().deactivate
);
app.post(
`${URL_PREFIX}/:did/create-resource`,
ResourceController.createValidator,
DidController.commonValidator,
new ResourceController().create
);

// cheqd-helpers
app.get(`${URL_PREFIX}/key-pair`, new CheqdController().generateKeys);
app.get(`${URL_PREFIX}/did-document`, CheqdController.didDocValidator, new CheqdController().generateDidDoc);

// 404 for all other requests
app.all('*', (req, res) => res.status(400).send('Bad request'));
}
}

export default new App().express
export default new App().express;
Loading

0 comments on commit dbc1d4a

Please sign in to comment.