Skip to content

Commit

Permalink
Upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
cooxe committed Apr 22, 2024
1 parent 2952171 commit fc58940
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 19 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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
with:
node-version: '20.x'
- run: npm install
- run: npm test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ coverage.html
*.log
yarn.lock
package-lock.json
.idea
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;
};
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
"name": "hapi-auto-route",
"version": "3.1.0",
"description": "Autoloads hapi routes",
"author": "Sitraka Ratsimba <ratsimbasitraka@gmail.com>",
"main": "lib/index.js",
"author": "Sitraka Ratsimba <sitraka@cooxe.com>",
"main": "index.js",
"keywords": [
"hapi",
"route",
"autoload"
],
"repository": "https://github.com/sitraka-hq/hapi-auto-route.git",
"bugs": "https://github.com/sitraka-hq/hapi-auto-route/issues",
"repository": "https://github.com/cooxe/hapi-auto-route.git",
"bugs": "https://github.com/cooxe/hapi-auto-route/issues",
"license": "MIT",
"scripts": {
"test": "lab --coverage --lint",
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 fc58940

Please sign in to comment.