Skip to content

Commit 7f37ec3

Browse files
committed
Update template.
1 parent d8b83fa commit 7f37ec3

File tree

12 files changed

+81
-43
lines changed

12 files changed

+81
-43
lines changed

.eslintrc.cjs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
node: true
5+
},
6+
extends: [
7+
'digitalbazaar',
8+
'digitalbazaar/jsdoc',
9+
'digitalbazaar/module'
10+
],
11+
ignorePatterns: ['node_modules/'],
12+
rules: {
13+
'unicorn/prefer-node-protocol': 'error'
14+
}
15+
};

.eslintrc.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
*.log
22
*.sw[nop]
33
*~
4-
.nyc_output
54
.project
65
.settings
76
.vscode
87
TAGS
98
coverage
109
node_modules
1110
reports
11+
package-lock.json

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
legacy-peer-deps=true

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ TBD
2525

2626
## Install
2727

28-
- Node.js 12+ is required.
28+
- Node.js 20+ is required.
2929

3030
### NPM
3131

3232
To install via NPM:
3333

3434
```
35-
npm install --save bedrock-module-template-http
35+
npm install --save @bedrock/module-template-http
3636
```
3737

3838
### Development

lib/config.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
/*!
2-
* Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
2+
* Copyright (c) 2025 Digital Bazaar, Inc. All rights reserved.
33
*/
4-
import bedrock from 'bedrock';
4+
import * as bedrock from '@bedrock/core';
55
const {config} = bedrock;
66

7-
const namespace = 'module-template-http';
7+
export const namespace = 'module-template-http';
88
const cfg = config[namespace] = {};
99

10-
const basePath = '/foo';
1110
cfg.routes = {
12-
basePath
11+
basePath: '/foo'
1312
};

lib/http.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
11
/*!
2-
* Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
2+
* Copyright (c) 2025 Digital Bazaar, Inc. All rights reserved.
33
*/
4-
import {asyncHandler} from 'bedrock-express';
5-
import bedrock from 'bedrock';
6-
const {config} = bedrock;
4+
import * as bedrock from '@bedrock/core';
5+
import {asyncHandler} from '@bedrock/express';
6+
import {createValidateMiddleware as validate} from '@bedrock/validation';
7+
import {example} from '../schemas/bedrock-template.js'
8+
9+
const {util: {BedrockError}} = bedrock;
710

811
bedrock.events.on('bedrock-express.configure.routes', app => {
9-
const {routes} = config['module-template-http'];
12+
const {config} = bedrock;
13+
const {routes} = config[namespace];
14+
1015
app.post(
1116
routes.basePath,
17+
validate({bodySchema: example}),
1218
asyncHandler(async (/*req, res*/) => {
13-
}));
19+
throw new BedrockError(
20+
'Not implemented.', {
21+
name: 'NotFoundError',
22+
details: {httpStatusCode: 501, public: true}
23+
});
24+
})
25+
);
1426
});

lib/index.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/*!
2-
* Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
2+
* Copyright (c) 2025 Digital Bazaar, Inc. All rights reserved.
33
*/
4-
'use strict';
4+
import '@bedrock/express';
55

6-
// translate `main.js` to CommonJS
7-
require = require('esm')(module);
8-
module.exports = require('./main.js');
6+
import './config.js';
7+
import './http.js';

lib/logger.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*!
2+
* Copyright (c) 2025 Digital Bazaar, Inc. All rights reserved.
3+
*/
4+
import {loggers} from '@bedrock/core';
5+
import {namespace} from './config.js';
6+
7+
export const logger = loggers.get('app').child(namespace);

lib/main.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)