Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
cooxe committed Apr 22, 2024
1 parent cc99b81 commit 985d24e
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 34 deletions.
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: Build And Test

on: [push]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['14.21.3', '21.7.3']

steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
- run: npm install
- run: npm test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea/
node_modules/
coverage.html
*.log
Expand Down
37 changes: 19 additions & 18 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,12 @@

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
This project adheres to [Semantic Versioning](http://semver.org/).

### 2.0.3

- Fix issues [#10](https://github.com/sitrakary/hapi-auto-route/issues/10).
- Fix lint errors.

### 2.0.2

- Fix issues [#5](https://github.com/sitrakary/hapi-auto-route/issues/5).

### 2.0.3

- Update dependencies.

## 3.0.0
### 3.1.0

- `routes_dir` requires an absolute path and must set in plugin registration.
- Updates dependencies.
- `routes_dir` accepts an array of parameters.
- Updates documentation.

### 3.0.1
Expand All @@ -39,7 +26,21 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

- Fix unpublished version

### 3.1.0
## 3.0.0

- `routes_dir` accepts an array of parameters.
- `routes_dir` requires an absolute path and must set in plugin registration.
- Updates dependencies.
- Updates documentation.

### 2.0.3

- Fix issues [#10](https://github.com/sitrakary/hapi-auto-route/issues/10).
- Fix lint errors.

### 2.0.2

- Fix issues [#5](https://github.com/sitrakary/hapi-auto-route/issues/5).

### 2.0.1

- Update dependencies.
19 changes: 10 additions & 9 deletions lib/auto-route.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@

const Glob = require('glob');
const Hoek = require('@hapi/hoek');
const Joi = require('@hapi/joi');
const Joi = require('joi');
const Path = require('path');
const Util = require('util');
const Prefix = require('./prefix');

module.exports.getFiles = (baseDir, pattern) => {

if (Array.isArray(baseDir)) {
const promise = new Promise((resolve, reject) => {
return new Promise((resolve) => {

Promise.all(baseDir.map((d) => this.getFiles(d, pattern)))
.then((value) => resolve(Hoek.flatten(value)));
});
return promise;
}

const absolutePattern = Path.join(baseDir, pattern);
Expand All @@ -37,8 +36,8 @@ module.exports.getRoutes = (filepaths) => {

const routes = files.filter((file) => {

const { error } = Joi.validate(file, multipleRoutesAllowed);
return error === null;
const result = multipleRoutesAllowed.validate(file);
return !Object.keys(result).includes('error');
});

return routes.map((file) => Hoek.clone(file));
Expand Down Expand Up @@ -89,12 +88,14 @@ module.exports.updatePaths = (prefixes, routes, stripTrailingSlash) => {
module.exports.validateOptions = (options) => {

const optionsSchema = Joi.object().keys({
routes_dir: Joi.alternatives(Joi.string(), Joi.array().items(Joi.string())).required(),
routes_dir: Joi.alternatives().try(Joi.string(), Joi.array().items(Joi.string())).required(),
pattern: Joi.string().default('**/!(_)*.js'),
use_prefix: Joi.boolean().default(false)
});

const { error, value } = Joi.validate(options, optionsSchema);
Hoek.assert(error === null, 'Invalid options are passed to hapi-auto-route');
return value;
const result = optionsSchema.validate(options);

Hoek.assert(!Object.keys(result).includes('error'), 'Invalid options are passed to hapi-auto-route');

return result.value;
};
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "hapi-auto-route",
"version": "3.1.0",
"description": "Autoloads hapi routes",
"author": "Sitraka Ratsimba <ratsimbasitraka@gmail.com>",
"author": "Sitraka Ratsimba <sitraka@cooxe.com>",
"main": "index.js",
"keywords": [
"hapi",
Expand All @@ -23,14 +23,14 @@
"README.md"
],
"devDependencies": {
"@hapi/code": "6.x.x",
"@hapi/hapi": "18.x.x",
"@hapi/eslint-plugin-hapi": "4.x.x",
"@hapi/lab": "20.x.x"
"@hapi/code": "9.x.x",
"@hapi/hapi": "21.x.x",
"@hapi/eslint-plugin": "6.x.x",
"@hapi/lab": "25.x.x"
},
"dependencies": {
"@hapi/hoek": "8.x.x",
"@hapi/joi": "15.x.x",
"@hapi/hoek": "11.x.x",
"joi": "17.x.x",
"glob": "7.x.x"
}
}

0 comments on commit 985d24e

Please sign in to comment.