Skip to content

Commit da30072

Browse files
committed
re-created example repeating tutorial steps
1 parent 65c49a3 commit da30072

File tree

10 files changed

+90
-418
lines changed

10 files changed

+90
-418
lines changed

pact/pact-node-provider/.gitignore

Lines changed: 16 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,21 @@
1-
# Logs
2-
logs
3-
*.log
4-
npm-debug.log*
5-
yarn-debug.log*
6-
yarn-error.log*
7-
8-
# Runtime data
9-
pids
10-
*.pid
11-
*.seed
12-
*.pid.lock
13-
14-
# Directory for instrumented libs generated by jscoverage/JSCover
15-
lib-cov
16-
17-
# Coverage directory used by tools like istanbul
18-
coverage
19-
20-
# nyc test coverage
21-
.nyc_output
22-
23-
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24-
.grunt
25-
26-
# Bower dependency directory (https://bower.io/)
27-
bower_components
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
282

29-
# node-waf configuration
30-
.lock-wscript
3+
# dependencies
4+
/node_modules
315

32-
# Compiled binary addons (https://nodejs.org/api/addons.html)
33-
build/Release
6+
# testing
7+
/coverage
348

35-
# Dependency directories
36-
node_modules/
37-
jspm_packages/
9+
# production
10+
/build
3811

39-
# Typescript v1 declaration files
40-
typings/
12+
# misc
13+
.DS_Store
14+
.env.local
15+
.env.development.local
16+
.env.test.local
17+
.env.production.local
4118

42-
# Optional npm cache directory
43-
.npm
44-
45-
# Optional eslint cache
46-
.eslintcache
47-
48-
# Optional REPL history
49-
.node_repl_history
50-
51-
# Output of 'npm pack'
52-
*.tgz
53-
54-
# Yarn Integrity file
55-
.yarn-integrity
56-
57-
# dotenv environment variables file
58-
.env
59-
60-
# next.js build output
61-
.next
19+
npm-debug.log*
20+
yarn-debug.log*
21+
yarn-error.log*

pact/pact-node-provider/app.js

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,27 @@
1-
const createError = require('http-errors');
21
const express = require('express');
32
const path = require('path');
3+
const cookieParser = require('cookie-parser');
44
const logger = require('morgan');
5+
6+
const indexRouter = require('./routes/index');
7+
const usersRouter = require('./routes/users');
58
const heroesRouter = require('./routes/heroes');
6-
const providerStateRouter = require('./routes/provider_state');
9+
const providerStateRouter = require ('./routes/provider_state');
10+
711
const app = express();
812

913
app.use(logger('dev'));
1014
app.use(express.json());
11-
app.use(express.urlencoded({extended: false}));
15+
app.use(express.urlencoded({ extended: false }));
16+
app.use(cookieParser());
17+
app.use(express.static(path.join(__dirname, 'public')));
1218

19+
app.use('/', indexRouter);
20+
app.use('/users', usersRouter);
1321
app.use('/heroes', heroesRouter);
1422

15-
registerPactEndpoint();
16-
17-
// catch 404 and forward to error handler
18-
app.use(function (req, res, next) {
19-
next(createError(404));
20-
});
23+
if (process.env.PACT_MODE === 'true') {
24+
app.use('/provider-state', providerStateRouter);
25+
}
2126

2227
module.exports = app;
23-
24-
/**
25-
* Registers a special endpoint for pact provider tests that allows to
26-
* set the server into a certain "provider state".
27-
*
28-
* This endpoint is only registered if the environment variable "PACT_MODE"
29-
* is set to "true".
30-
*/
31-
function registerPactEndpoint() {
32-
const pactMode = (process.env.PACT_MODE === 'true');
33-
if (pactMode) {
34-
app.use('/provider-state', providerStateRouter);
35-
}
36-
}

pact/pact-node-provider/bin/www.js renamed to pact/pact-node-provider/bin/www

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
var app = require('../app');
8-
var debug = require('debug')('pact-node-provider:server');
8+
var debug = require('debug')('test:server');
99
var http = require('http');
1010

1111
/**

0 commit comments

Comments
 (0)