switch to yarn
This commit is contained in:
parent
9581fbf2b3
commit
9457505a4c
@ -1 +1 @@
|
|||||||
/test/
|
/test/
|
||||||
|
2
.npmrc
2
.npmrc
@ -1 +1 @@
|
|||||||
@scode:registry=https://npm.scode.ovh
|
@scode:registry=https://npm.scode.ovh
|
||||||
|
92
Jenkinsfile
vendored
92
Jenkinsfile
vendored
@ -1,46 +1,46 @@
|
|||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent any
|
||||||
|
|
||||||
environment {
|
environment {
|
||||||
VERSION = VersionNumber([
|
VERSION = VersionNumber([
|
||||||
versionNumberString:
|
versionNumberString:
|
||||||
'${BUILDS_ALL_TIME}',
|
'${BUILDS_ALL_TIME}',
|
||||||
versionPrefix: '1.1.',
|
versionPrefix: '1.1.',
|
||||||
worstResultForIncrement: 'SUCCESS'
|
worstResultForIncrement: 'SUCCESS'
|
||||||
])
|
])
|
||||||
publish = 0
|
publish = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
stage('Setup') {
|
stage('Setup') {
|
||||||
steps {
|
steps {
|
||||||
echo 'Setting up test environment'
|
echo 'Setting up test environment'
|
||||||
sh 'npm ci'
|
sh 'yarn --frozen-lockfile'
|
||||||
sh 'nodejs jenkins.js ${VERSION}'
|
sh 'nodejs jenkins.js ${VERSION}'
|
||||||
script {
|
script {
|
||||||
currentBuild.displayName = env.VERSION
|
currentBuild.displayName = env.VERSION
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Testing') {
|
stage('Testing') {
|
||||||
steps {
|
steps {
|
||||||
echo 'Running tests...'
|
echo 'Running tests...'
|
||||||
sh 'npm test'
|
sh 'npm test'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
post {
|
post {
|
||||||
success {
|
success {
|
||||||
script {
|
script {
|
||||||
publish = sh script: "git log -1 | grep '\\[no publish\\]'", returnStatus: true
|
publish = sh script: "git log -1 | grep '\\[no publish\\]'", returnStatus: true
|
||||||
if (publish != 0) {
|
if (publish != 0) {
|
||||||
echo 'Deploying'
|
echo 'Deploying'
|
||||||
sh 'npm publish'
|
sh 'yarn publish'
|
||||||
} else {
|
} else {
|
||||||
echo 'Build successful, Commit not marked for deploying'
|
echo 'Build successful, Commit not marked for deploying'
|
||||||
currentBuild.result = "UNSTABLE"
|
currentBuild.result = "UNSTABLE"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
140
README.md
140
README.md
@ -1,70 +1,70 @@
|
|||||||
# Requestor
|
# Requestor
|
||||||
|
|
||||||
Split express request handlers into individual files to make your api a little
|
Split express request handlers into individual files to make your api a little
|
||||||
more structured.
|
more structured.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
npmrc:
|
npmrc:
|
||||||
|
|
||||||
used to set the registry for @scode
|
used to set the registry for @scode
|
||||||
|
|
||||||
```npmrc
|
```npmrc
|
||||||
@scode:registry=https://npm.scode.ovh
|
@scode:registry=https://npm.scode.ovh
|
||||||
```
|
```
|
||||||
|
|
||||||
install the package:
|
install the package:
|
||||||
|
|
||||||
`npm i --save @scode/requestor`
|
`npm i --save @scode/requestor`
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
The path to which the individual modules respond is defined by their name.
|
The path to which the individual modules respond is defined by their name.
|
||||||
|
|
||||||
'.' is used as path separator.
|
'.' is used as path separator.
|
||||||
|
|
||||||
`method-subdir.subdir.subdir.js`
|
`method-subdir.subdir.subdir.js`
|
||||||
|
|
||||||
method can be any of [post, get, put, delete, all]
|
method can be any of [post, get, put, delete, all]
|
||||||
|
|
||||||
to avoid names like `get-.js` root is used for the root directory
|
to avoid names like `get-.js` root is used for the root directory
|
||||||
(`get-root.js`)
|
(`get-root.js`)
|
||||||
|
|
||||||
index.js:
|
index.js:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const requestor = require('requestor');
|
const requestor = require('requestor');
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
requestor(app, 'api', {opts: {foo: 'bar'}});
|
requestor(app, 'api', {opts: {foo: 'bar'}});
|
||||||
app.listen(3000);
|
app.listen(3000);
|
||||||
```
|
```
|
||||||
|
|
||||||
api/get-root.js
|
api/get-root.js
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// will respond to get requests on /
|
// will respond to get requests on /
|
||||||
module.exports = (req, res, next, opts) => {
|
module.exports = (req, res, next, opts) => {
|
||||||
res.send(opts.foo);
|
res.send(opts.foo);
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
api/post-subfolder.js
|
api/post-subfolder.js
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// will respond to post requests on /subfolder/
|
// will respond to post requests on /subfolder/
|
||||||
module.exports = (req, res, next, opts) => {
|
module.exports = (req, res, next, opts) => {
|
||||||
res.send(opts.foo);
|
res.send(opts.foo);
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
optionally, you can set a subdirectory for all requests
|
optionally, you can set a subdirectory for all requests
|
||||||
|
|
||||||
```js
|
```js
|
||||||
//...
|
//...
|
||||||
|
|
||||||
requestor(app, 'api', {subdir: 'subdir'});
|
requestor(app, 'api', {subdir: 'subdir'});
|
||||||
|
|
||||||
// requests that before responded to /foo/bar/ will now respond to /subdir/foo/bar/
|
// requests that before responded to /foo/bar/ will now respond to /subdir/foo/bar/
|
||||||
```
|
```
|
||||||
|
2281
package-lock.json
generated
2281
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user