Skip to content

Commit 6ef0f71

Browse files
committed
Initial commit
0 parents  commit 6ef0f71

16 files changed

+374
-0
lines changed

.eslintrc.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
node: true
5+
},
6+
extends: 'digitalbazaar'
7+
};

.github/workflows/main.yml

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Bedrock Node.js CI
2+
3+
on: [push]
4+
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
timeout-minutes: 10
9+
strategy:
10+
matrix:
11+
node-version: [14.x]
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Use Node.js ${{ matrix.node-version }}
15+
uses: actions/setup-node@v1
16+
with:
17+
node-version: ${{ matrix.node-version }}
18+
- run: npm install
19+
- name: Run eslint
20+
run: npm run lint
21+
test-node:
22+
needs: [lint]
23+
runs-on: ubuntu-latest
24+
timeout-minutes: 10
25+
services:
26+
mongodb:
27+
image: mongo:4.2
28+
ports:
29+
- 27017:27017
30+
strategy:
31+
matrix:
32+
node-version: [12.x, 14.x]
33+
steps:
34+
- uses: actions/checkout@v2
35+
- name: Use Node.js ${{ matrix.node-version }}
36+
uses: actions/setup-node@v1
37+
with:
38+
node-version: ${{ matrix.node-version }}
39+
- run: |
40+
cd test
41+
npm install
42+
- name: Run test with Node.js ${{ matrix.node-version }}
43+
run: |
44+
cd test
45+
npm test
46+
coverage:
47+
needs: [test-node]
48+
runs-on: ubuntu-latest
49+
timeout-minutes: 10
50+
services:
51+
mongodb:
52+
image: mongo:4.2
53+
ports:
54+
- 27017:27017
55+
strategy:
56+
matrix:
57+
node-version: [14.x]
58+
steps:
59+
- uses: actions/checkout@v2
60+
- name: Use Node.js ${{ matrix.node-version }}
61+
uses: actions/setup-node@v1
62+
with:
63+
node-version: ${{ matrix.node-version }}
64+
- run: |
65+
cd test
66+
npm install
67+
- name: Generate coverage report
68+
run: |
69+
cd test
70+
npm run coverage-ci
71+
- name: Upload coverage to Codecov
72+
uses: codecov/codecov-action@v1
73+
with:
74+
file: ./test/coverage/lcov.info
75+
fail_ci_if_error: true

.gitignore

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
*.log
2+
*.sw[nop]
3+
*~
4+
.nyc_output
5+
.project
6+
.settings
7+
.vscode
8+
TAGS
9+
coverage
10+
node_modules
11+
reports

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# bedrock-module-template-http ChangeLog
2+
3+
## 1.0.0 - TBD
4+
5+
- See git history for changes.

LICENSE.md

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
Bedrock Non-Commercial License v1.0
2+
===================================
3+
4+
Copyright (c) 2011-2021 Digital Bazaar, Inc.
5+
All rights reserved.
6+
7+
Summary
8+
=======
9+
10+
This license allows the licensee to use Bedrock and its software modules
11+
for non-commercial purposes such as self-study, research, personal
12+
projects, or for evaluation purposes. If the licensee uses Bedrock
13+
directly or indirectly to generate revenue, or to provide products or
14+
services to more than 500 people (users), the licensee must immediately
15+
obtain a non-profit or commercial license.
16+
17+
Examples
18+
========
19+
20+
These are examples of cases that are allowed by this license:
21+
22+
* The licensee is an individual that creates Bedrock-dependent software for
23+
personal use only.
24+
* The licensee is an individual or group of students/researchers that uses
25+
Bedrock to experiment with an idea for a non-commercial project.
26+
* The licensee is a startup company that prototypes a Bedrock-dependent
27+
product before they have cash flow and will be testing the prototype
28+
software with less than 500 users. The service will not generate revenue
29+
of any kind.
30+
* The licensee is a for-profit organization that creates a product or
31+
service that is used by less than 500 users and is built with or
32+
integrates with Bedrock. The service must be exclusively provided for free
33+
and no parent, subsidiary, agent, or affiliate organization may profit
34+
from its use.
35+
36+
These cases require a non-profit or commercial license:
37+
38+
* The licensee is a non-profit that receives funding to create and/or run a
39+
Bedrock-dependent service.
40+
* The licensee is a startup company with Bedrock-dependent software that is
41+
funded by another organization.
42+
* The licensee is a startup company that is going into production with
43+
Bedrock-dependent software.
44+
* The licensee has more than 500 users using a Bedrock-dependent service
45+
either directly or indirectly.
46+
* The licensee is a medium to large organization that builds or integrates a
47+
commercial product or service with Bedrock.
48+
49+
THE LICENSE
50+
===========
51+
52+
This section and all subsequent sections of this document constitute the
53+
agreement between the licensee and Digital Bazaar, Inc.
54+
55+
DEFINITIONS
56+
===========
57+
58+
* Product - The Bedrock software and any modules associated with Bedrock
59+
where Digital Bazaar, Inc. owns the copyright.
60+
61+
CONDITIONS
62+
==========
63+
64+
Redistribution and use in source and binary forms, with or without
65+
modification, are permitted for NON-COMMERCIAL PURPOSES as long as the
66+
following conditions are met:
67+
68+
1. Any use of the Product must not generate revenue for the licensee or
69+
any parent, subsidiary, agent, or affiliate of the licensee. Use of
70+
Product includes, but is not limited to, interacting with any of the
71+
licensee's Product-dependent products or services over a network.
72+
73+
2. The aggregate number of individual people (users) of the licensee's
74+
products or services that use Product must be less than 500.
75+
76+
3. Redistributions of source code must retain the above copyright notice
77+
intact, this list of conditions and the following disclaimer.
78+
79+
4. Redistributions in binary form must reproduce the above copyright
80+
notice, this license and the following disclaimer in the documentation and
81+
on a web page available via interactive use and/or other materials
82+
provided with the distribution.
83+
84+
5. Neither the name of the copyright holder, the names of its
85+
contributors, nor any trademarks held by the copyright holder may be used
86+
to endorse or promote products or services built using the Product without
87+
specific prior written permission.
88+
89+
6. Any modifications are clearly outlined in release documentation and are
90+
specifically mentioned as not being a part of an official Product release.
91+
No additional restrictions to this license may be made when distributing
92+
modifications.
93+
94+
7. For the avoidance of doubt, this license prohibits sublicensing of the
95+
Product.
96+
97+
8. Any breach of this license by licensee must be resolved within 30 days.
98+
Failure to do so results in the termination of this license.
99+
100+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
101+
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
102+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
103+
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
104+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
105+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
106+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
107+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
108+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
109+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
110+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
111+
112+
To obtain a non-profit or commercial license for Product, please contact
113+
Digital Bazaar, Inc. at the following email address:
114+
115+
Digital Bazaar <[email protected]>

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# bedrock-module-template-http

lib/config.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*!
2+
* Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
3+
*/
4+
import bedrock from 'bedrock';
5+
const {config} = bedrock;
6+
7+
const namespace = 'module-template-http';
8+
const cfg = config[namespace] = {};
9+
10+
const basePath = '/foo';
11+
cfg.routes = {
12+
basePath
13+
};

lib/http.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*!
2+
* Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
3+
*/
4+
import {asyncHandler} from 'bedrock-express';
5+
import bedrock from 'bedrock';
6+
const {config} = bedrock;
7+
8+
bedrock.events.on('bedrock-express.configure.routes', app => {
9+
const {routes} = config['module-template-http'];
10+
app.post(
11+
routes.basePath,
12+
asyncHandler(async (/*req, res*/) => {
13+
}));
14+
});

lib/index.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*!
2+
* Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
3+
*/
4+
'use strict';
5+
6+
// translate `main.js` to CommonJS
7+
require = require('esm')(module);
8+
module.exports = require('./main.js');

lib/main.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*!
2+
* Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
3+
*/
4+
import 'bedrock-express';
5+
6+
import './config.js';
7+
import './http.js';

package.json

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "bedrock-module-template-http",
3+
"version": "0.0.1-0",
4+
"description": "Bedrock HTTP API",
5+
"main": "./lib",
6+
"scripts": {
7+
"lint": "eslint ."
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "https://github.com/digitalbazaar/bedrock-module-template-http"
12+
},
13+
"keywords": [
14+
"bedrock"
15+
],
16+
"author": {
17+
"name": "Digital Bazaar, Inc.",
18+
"email": "[email protected]",
19+
"url": "https://digitalbazaar.com"
20+
},
21+
"bugs": {
22+
"url": "https://github.com/digitalbazaar/bedrock-module-template-http/issues"
23+
},
24+
"homepage": "https://github.com/digitalbazaar/bedrock-module-template-http",
25+
"dependencies": {
26+
"esm": "^3.2.25"
27+
},
28+
"peerDependencies": {
29+
"bedrock": "^4.1.1",
30+
"bedrock-express": "^3.2.0"
31+
},
32+
"directories": {
33+
"lib": "./lib"
34+
},
35+
"devDependencies": {
36+
"eslint": "^7.14.0",
37+
"eslint-config-digitalbazaar": "^2.6.1"
38+
},
39+
"engines": {
40+
"node": ">=12"
41+
}
42+
}

test/mocha/.eslintrc

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"env": {
3+
"mocha": true
4+
},
5+
"globals": {
6+
"assertNoError": true,
7+
"should": true
8+
}
9+
}

test/mocha/10-api.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*
2+
* Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
3+
*/
4+
5+
describe('api', () => {
6+
it('should work');
7+
});

test/package.json

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "bedrock-module-template-http-test",
3+
"version": "0.0.1-0",
4+
"private": true,
5+
"scripts": {
6+
"test": "node --preserve-symlinks test.js test",
7+
"coverage": "cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text-summary npm test",
8+
"coverage-ci": "cross-env NODE_ENV=test nyc --reporter=lcovonly npm test",
9+
"coverage-report": "nyc report"
10+
},
11+
"dependencies": {
12+
"bedrock": "^4.1.1",
13+
"bedrock-express": "^3.2.0",
14+
"bedrock-https-agent": "^2.0.0",
15+
"bedrock-module-template-http": "file:..",
16+
"bedrock-mongodb": "^8.2.0",
17+
"bedrock-server": "^2.7.0",
18+
"bedrock-test": "^5.3.2",
19+
"cross-env": "^7.0.3",
20+
"nyc": "^15.1.0"
21+
},
22+
"nyc": {
23+
"excludeNodeModules": false,
24+
"include": [
25+
"node_modules/bedrock-module-template-http/**"
26+
],
27+
"exclude": [
28+
"node_modules/bedrock-module-template-http/node_modules/**"
29+
]
30+
}
31+
}

test/test.config.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
3+
*/
4+
'use strict';
5+
6+
const {config} = require('bedrock');
7+
const path = require('path');
8+
9+
// MongoDB
10+
config.mongodb.name = 'bedrock_module_template_http_test';
11+
config.mongodb.dropCollections.onInit = true;
12+
config.mongodb.dropCollections.collections = [];
13+
14+
config.mocha.tests.push(path.join(__dirname, 'mocha'));
15+
16+
// allow self-signed certs in test framework
17+
config['https-agent'].rejectUnauthorized = false;

test/test.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
3+
*/
4+
'use strict';
5+
6+
const bedrock = require('bedrock');
7+
require('bedrock-https-agent');
8+
require('bedrock-mongodb');
9+
require('bedrock-module-template-http');
10+
11+
require('bedrock-test');
12+
bedrock.start();

0 commit comments

Comments
 (0)