Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update fastify to v3 #12

Merged
merged 4 commits into from
May 19, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .dependabot/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version: 1
update_configs:
- package_manager: "javascript"
directory: "/"
update_schedule: "daily"
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: CI workflow
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x, 12.x, 14.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install Dependencies
run: npm install --ignore-scripts
- name: Test
run: npm test
13 changes: 0 additions & 13 deletions .travis.yml

This file was deleted.

3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# fastify-routes
[![Greenkeeper badge](https://badges.greenkeeper.io/fastify/fastify-routes.svg)](https://greenkeeper.io/)

[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) [![Build Status](https://travis-ci.org/fastify/fastify-routes.svg?branch=master)](https://travis-ci.org/fastify/fastify-routes)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

This plugin decorates Fastify instance with `routes` which is a [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) of registered routes. Note that you have to register this plugin
before registering any routes so that it can collect all of them.
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "A plugin for Fastify that provides a map of routes",
"main": "plugin.js",
"scripts": {
"test": "tap --cov test/**/*.test.js",
"test": "npm run lint && npm run unit",
"unit": "tap --cov test/**/*.test.js",
"lint": "standard | snazzy"
},
"precommit": [
Expand All @@ -26,13 +27,13 @@
},
"homepage": "https://github.com/fastify/fastify-routes#readme",
"devDependencies": {
"fastify": "^2.0.0",
"fastify": "^3.0.0-rc.1",
"pre-commit": "^1.2.2",
"snazzy": "^8.0.0",
"standard": "^14.0.2",
"tap": "^12.0.1"
},
"dependencies": {
"fastify-plugin": "^1.2.0"
"fastify-plugin": "^2.0.0"
}
}
35 changes: 13 additions & 22 deletions test/routes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,20 @@ function handler (_, reply) {
reply.send({ hello: 'world' })
}

const schema = {
response: {
200: {
type: 'object',
properties: {
hello: { type: 'string' }
}
}
}
}

const routeA = function (fastify, opts, next) {
const options = {
schema: {
response: {
200: {
type: 'object',
properties: {
hello: { type: 'string' }
}
}
}
},
schema,
bodyLimit: 1000,
logLevel: 'warn'
}
Expand Down Expand Up @@ -66,18 +68,7 @@ test('should correctly map routes', (t) => {
t.equal(fastify.routes.get('/v1/hello/:world').get.prefix, '/v1')
t.equal(fastify.routes.get('/v1/hello/:world').get.bodyLimit, 1000)
t.equal(fastify.routes.get('/v1/hello/:world').get.handler, handler)
t.deepEqual(fastify.routes.get('/v1/hello/:world').get.schema, {
response: {
200: {
properties: {
hello: {
type: 'string'
}
},
type: 'object'
}
}
})
t.deepEqual(fastify.routes.get('/v1/hello/:world').get.schema, schema)

t.equal(fastify.routes.get('/v1/hello/:world').post.method, 'POST')
t.equal(fastify.routes.get('/v1/hello/:world').post.url, '/v1/hello/:world')
Expand Down