🚀 A RESTful API generator for Node.js

Overview

rest-hapi logo


rest-hapi title

A RESTful API generator rest-hapi tweet

rest-hapi is a hapi plugin that generates RESTful API endpoints based on mongoose schemas. It provides a powerful combination of relational structure with NoSQL flexibility. You define your data models and the rest is done for you. Have your API up and running in minutes!

Features


Live demo

rest-hapi-demo-optimized

View the swagger docs for the live demo:

https://demo.resthapi.com

Or, for a more complete example, check out the appy api:

https://api.appyapp.io

Documentation

Check out the docs on the official site!

Requirements

You need Node.js installed and you'll need MongoDB installed and running.

Quick Start

rest-hapi-demo-alt-optimized

(NOTE: For an alternative quick start, check out his awesome yeoman generator for rest-hapi.)

  1. Clone the demo repo
$ git clone https://github.com/JKHeadley/rest-hapi-demo.git
$ cd rest-hapi-demo
  1. Install the dependencies
$ npm install
  1. Seed the models
$ ./node_modules/.bin/rest-hapi-cli seed
  1. Start the server
$ npm start
  1. View the API docs at

http://localhost:8080/

...have fun!

Example Projects

appy: A boilerplate web app.

rest-hapi-demo: A simple demo project implementing rest-hapi in a hapi server.

Contributing

We welcome contributions to rest-hapi! These are the many ways you can help:

Please read our contribution guide to get started. Also note that this project is released with a Contributor Code of Conduct, please make sure to review and follow it.

Contributors

Thanks goes to each one of our contributors! 🙏

Become a contributor.

Backers

Support us with a monthly donation and help us continue our activities! Become a backer.

Questions?

If you have any questions/issues/feature requests, please feel free to open an issue. We'd love to hear from you!

Support

Like this project? Please star it!

License

rest-hapi is licensed under a MIT License.

Comments
  • Allow, flexible object fields for models.

    Allow, flexible object fields for models.

    I have a requirement, where I want to allow the users of my service to input any data into my model. Some metadata.

    I have tried using Types.Mixed and Types.Object to get past this, but when I make a request, rest-hapi says key is not allowed. I think this was working uptil v 0.20, I recently updated to 0.33.

    Thanks in advance.

    opened by rahil471 17
  • Feature/hapi server config

    Feature/hapi server config

    1. Minor commit to include code-cov as part of dev dependency
    2. Support for baseUrl in REST-HAPI
    3. pass through hapi-swagger configuration as an option.
    4. Support all legacy options, but those get overridden when config.swaggerOptions is set (as per hapi-swagger documentation).
    5. Additionally some swaggerOptions are over-written.
    opened by shiva 11
  • Proposal: updateHandler to use findById() + findOneAndUpdate()

    Proposal: updateHandler to use findById() + findOneAndUpdate()

    Using the recent changes/additions to the middleware, I've been able to have my create, list and find endpoints use the authenticated user's credentials. For example:

          create: {
            pre: function(payload, request, Log) {
              payload.account = request.auth.credentials.account;
              return Promise.resolve(payload);
            },
          },
          list: {
            pre: function(query, request, Log) {
              query.account = request.auth.credentials.account;
              return Promise.resolve(query);
            },
          },
    

    Now I'm working on adding the same functionality to the update endpoint. Currently the update handler simply calls model.findByIdAndUpdate(_id, payload). I propose changing this to:

    mongooseQuery = model.findById(_id);
    mongooseQuery = QueryHelper.createMongooseQuery(model, query, mongooseQuery, Log);
    mongooseQuery.findOneAndUpdate(payload)
    

    This way, the document specified by _id will only be found and updated if it also matches any additional constraints in the query.


    I have a proof-of-concept implementation at https://github.com/pangeamedia/rest-hapi/commit/fea600d713dce4f59b92bcb2ac7637399039b017#diff-cae92e718d9d94bbd9debab4fbf43095L734 I've tested this POC in my app, and it works as expected.

    The main difficulty is that the update.pre middleware function currently only returns the payload, but I need it to return the query. For the proof-of-concept, I have update.pre return the query as payload.$query. This is not ideal, but it maintains backwards compatibility.

    Other ideas I had include update.pre returning an object like { payload: payload, query: query } or an array like [ payload, query ], possibly maintaining backwards compatibility in either case by having the update handler introspect the returned value. I don't know what approach is best.

    Thoughts?

    enhancement 
    opened by tamias 9
  • getAll request on '_MANY' association

    getAll request on '_MANY' association

    Describe the bug I want to get '_MANY' association and rest-hapi return all datas of the model of association

    To Reproduce Steps to reproduce the behavior:

    1. Create '_MANY' association
    associations: {
    	companies: {
    		type: '_MANY',
    		alias: 'companies',
    		model: 'companies',
    	},
    },
    
    1. I am creating companies in the model companies
    Capture d’écran 2019-08-22 à 18 07 04
    1. I post an id company in my companies association
    Capture d’écran 2019-08-22 à 18 19 53
    1. I get the association companies and response contains all the companies whereas in the companies association i have only one company
    {
      "docs": [
        {
          "_id": "5d5cae2e3356752c4f2d4414",
          "subsidiaries": [
            {
              "_id": "5d5cae373356752c4f2d4416",
              "subsidiaries": [],
              "name": "string",
              "naf": "string",
              "siret": "string",
              "createdBy": "5d5c9e1a6b233e246ad4f611",
              "createdAt": "2019-08-21T02:36:39.450Z",
              "institutions": []
            }
          ],
          "name": "string",
          "naf": "string",
          "siret": "string",
          "createdBy": "5d5c9e1a6b233e246ad4f611",
          "createdAt": "2019-08-21T02:36:30.548Z",
          "institutions": []
        },
        {
          "_id": "5d5cae373356752c4f2d4416",
          "subsidiaries": [],
          "name": "string",
          "naf": "string",
          "siret": "string",
          "createdBy": "5d5c9e1a6b233e246ad4f611",
          "createdAt": "2019-08-21T02:36:39.450Z",
          "institutions": []
        },
        {
          "_id": "5d5ebd0207b9b804f763dc2a",
          "subsidiaries": [],
          "name": "Hey",
          "naf": "string",
          "siret": "string",
          "createdBy": "5d5db71b1c99220acc90ae45",
          "createdAt": "2019-08-22T16:04:18.189Z",
          "institutions": []
        }
      ],
      "pages": {
        "current": 1,
        "prev": 0,
        "hasPrev": false,
        "next": 2,
        "hasNext": false,
        "total": null
      },
      "items": {
        "begin": null,
        "end": null,
        "total": 3
      }
    }
    

    Expected behavior getAll request on '_MANY' association should return only the id's of the association and not fulld datas of the corresponding model.

    Desktop (please complete the following information):

    • OS: OSX
    • Browser: Chrome
    • Version: 76.0.3809.100

    Additional context Sorry for my deplorable English, i hope its comprehensive ! Thanks for your answer.

    opened by clegirar 8
  • How to do some enhancement or changes in existing API created automatically by Rest-Hapi.

    How to do some enhancement or changes in existing API created automatically by Rest-Hapi.

    Hi, First of all thanks for providing awesome module like rest-hapi. I required so many time that if there is somehow i can change or modify the auto created API according to my requirement. Like if i add one flag, if that flag value is true than i call one of my method and than append the result of my method with the result we are going to send to the client. Is this functionality currently exists or not and if exists than would appreciate if you please let me know.

    Thanks

    opened by techloverparveen 7
  • Sort and search by many_one associations fields

    Sort and search by many_one associations fields

    Is your feature request related to a problem? Please describe. I'm trying to build a frontend with searchable and sortable tables having one "main" collection with where many of the tables columns are many_one associations.

    Simplified example:

    MainName | sub1.name | sub1.sub2.name -------------|-------------|------------- name1 |sub1Name1| sub2Name1 name2 |sub1Name2| sub2Name1 name3 |sub1Name1| sub2Name2

    I need to be able to filter on the sub fields for now I have to move the data of sub fields to the main collection to accomplish this.

    This means that I have a fields in the main collection that has to be updated if the associations name filed is updated and in my project there are even worse nested associations that needs to be accessible from the main field like:

    Main.sub1.sub2.sub3.name
    

    And every sub doc has its own table on the frontend. In my solution if sub3.name is updated I now need to update every parent after each other in order and doing this in with the update: {post: () => RestHapi.update() } and update: {pre: () => payloade.subName = ... } middleware on each layer.

    sub3.model

    update: {
      post: async function (request, result, Log) {
        // get sub2s that has sub3s
        const sub2s = await mongoose
          .model("sub2")
          .find({ sub3: result._id });
        
        // uppdate sub2
        await Promise.all(
          sub2s.map(sub2=> 
            RestHapi.update('sub2', sub2._id, {sub3: result._id})
          )
        )
      }
    }
    

    sub2.model

    update: {
      pre: async function(_id, payload, request, Log) {
        // uppdates sub3 name
        if(payload.sub3) {
          const sub3= await mongoose
            .model("sub3")
            .findOne({ _id: payload.sub3});
    
          payload.sub3Name = sub3.name;
        }
    
        return payload
      },
      post: async function (request, result, Log) {
        // get sub1s that has sub2s
        const sub1s = await mongoose
          .model("sub1")
          .find({ sub2: result._id });
        
        // uppdate sub1
        await Promise.all(
          sub1s.map(sub1=> 
            RestHapi.update('sub1', sub1._id, { sub2: result._id })
          )
        )
      }
    }
    

    sub1.model

    update: {
      pre: async function(_id, payload, request, Log) {
        // uppdates sub2 and sub3 name
        if(payload.sub2) {
          const sub2= await mongoose
            .model("sub2")
            .findOne({ _id: payload.sub2});
    
          payload.sub3Name = sub2.sub3Name;
          payload.sub2Name = sub2.name;
        }
    
        return payload
      },
      post: async function (request, result, Log) {
        // get mains that has sub1s
        const mains = await mongoose
          .model("main")
          .find({ sub1: result._id });
        
        // uppdate sub1
        await Promise.all(
          mains.map(main => 
            RestHapi.update('main ', main ._id, { sub1: result._id })
          )
        )
      }
    }
    

    main.model

    update: {
      pre: async function(_id, payload, request, Log) {
        // uppdates sub1, sub2 and sub3 name
        if(payload.sub1) {
          const sub1= await mongoose
            .model("sub1")
            .findOne({ _id: payload.sub1});
    
          payload.sub3Name = sub1.sub3Name;
          payload.sub2Name = sub1.sub2Name;
          payload.sub1Name = sub1.name;
        }
    
        return payload
      },
      post: async function (request, result, Log) {
        // get mains that has sub1s
        const mains = await mongoose
          .model("main")
          .find({ sub1: result._id });
        
        // uppdate sub1
        await Promise.all(
          mains.map(main => 
            RestHapi.update('main ', main ._id, { sub1: result._id })
          )
        )
      }
    }
    

    I'm also setting the "moved fields" on create manually in the create middleware on each layer. and now I'm able to filter and search even on sub3Name from my main collection.

    Performance wise this is bad really bad if I have many main documents.. and if any fails I'm screwed.

    Describe the solution you'd like I need to be able to search and sort by sub1.name I'm not sure if this is doable at all even on a lower level..

    opened by yoieh 6
  • How to define indexs in rest-hapi schema?

    How to define indexs in rest-hapi schema?

    Hi, I want to define indexes in a rest-hapi schema. In ExpressJs we have to define indexes in the schema like that:- var userSchema = new Schema({ name: String, location: { type: {type: String}, coordinates: [] } // field level }); userSchema.index({ location: '2dsphere' }); // schema level

    opened by arunkatariaoodles 6
  • Linking Models are saved in the same model as array (they should be saved in different collection) so what if maximum size of document exceed i.e 16 MB?

    Linking Models are saved in the same model as array (they should be saved in different collection) so what if maximum size of document exceed i.e 16 MB?

    Hi JKHeadley, I am just wondering to know that you create linking models for many to many relationship . And the relationship stores as an array on the same model, so what i am thinking because so many relationship would be there so that document size become heavy. So that will create issue after some time because maximum size of an document we have in Mongo is of 16 MB.

    According to me there should be separate collection for the linking models.

    So i just want to know your view on this means you are working on it or you see this differently, or i am wrong here please correct me.

    Thanks

    opened by techloverparveen 6
  • Array of strings not working

    Array of strings not working

    Describe the bug I am creating a model with an array of string as one of it's properties but I can't insert data there.

    To Reproduce Steps to reproduce the behavior:

    1. Create a model with one properties as an Array of String
    //...
    new mongoose.Schema({
        name: Types.String,
        tags: [Types.String]
      });
    
    1. Try to insert some data like
    //...
    "tags": ["one", "two"]
    
    1. A 400 status code is received :
    {
    	"statusCode": 400,
    	"error": "Bad Request",
    	"message": "Invalid request payload input"
    }
    

    Expected behavior Tags data should be inserted

    Screenshots

    Desktop (please complete the following information):

    • OS: OSX
    • Browser Firefox
    • Version 1.3.3
    opened by mikaoelitiana 5
  • Error when starting rest-hapi plugin: Cannot set property 'Promise' of undefined

    Error when starting rest-hapi plugin: Cannot set property 'Promise' of undefined

    I tried for two hours to start rest-hapi demo project, but failed. Maybe I missed something. Would appreciate help. When node api.js get error:

    TypeError: Cannot set property 'Promise' of undefined
        at module.exports (/Users/mike/projects/a_learn/rest-hapi_test/node_modules/rest-hapi/components/mongoose-init.js:11:20)
        at Object.register (/Users/mike/projects/a_learn/rest-hapi_test/node_modules/rest-hapi/rest-hapi.js:67:57)
        at internals.Server.register (/Users/mike/projects/a_learn/rest-hapi_test/node_modules/hapi/lib/server.js:427:35)
        at api (/Users/mike/projects/a_learn/rest-hapi_test/api.js:31:18)
        at Object.<anonymous> (/Users/mike/projects/a_learn/rest-hapi_test/api.js:41:1)
        at Module._compile (module.js:652:30)
        at Object.Module._extensions..js (module.js:663:10)
        at Module.load (module.js:565:32)
        at tryModuleLoad (module.js:505:12)
        at Function.Module._load (module.js:497:3)
        at Function.Module.runMain (module.js:693:10)
        at startup (bootstrap_node.js:188:16)
        at bootstrap_node.js:609:3
    

    My package.json

    {
      "name": "rest-hapi_test",
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
      },
      "author": "",
      "license": "ISC",
      "dependencies": {
        "hapi": "^17.4.0",
        "mongoose": "^5.1.0",
        "rest-hapi": "^0.43.1"
      }
    }
    

    My api.js

    'use strict';
    
    let Hapi = require('hapi');
    let mongoose = require('mongoose');
    let restHapi = require('rest-hapi');
    
    async function api(){
    
        const server = new Hapi.Server(restHapi.config.server.connection);
    
        const plugins = [
            {
                name: 'restHapi',
                version: '1.0.0',
                register: restHapi.register,
                options: {
                    mongoose: mongoose
                }
            }
        ]
    
        await server.register(plugins);
        await server.start();
        console.log(`Server running at: ${server.info.uri}`); // eslint-disable-line
    }
    
    process.on('unhandledRejection', (err) => {
        console.error(err); // eslint-disable-line
        process.exit(1);
    });
    
    api();
    

    P.S. Also tried with canonical example from docs it does not work as well.

    opened by klishevich 5
  • TypeError: Cannot read property 'schemaName' of undefined

    TypeError: Cannot read property 'schemaName' of undefined

    Hi there. I keep running into this error when trying to startup my application. I've looked for help in Google, with no luck. Unfortunately i can't share much of the code, but here's the stacktrace:

    [18:18:32.087] 47383 NOTE     api/layout/List — Generating List endpoint for layout
    [18:18:32.093] 47383 ERROR    node_modules/rest-hapi/utilities/rest-helper-factory.js:98:16 api — Error: TypeError: Cannot read property 'schemaName' of undefined
    [18:18:32.093] 47383 ERROR    node_modules/rest-hapi/utilities/rest-helper-factory.js:98:16 api —     at Object.generateJoiModelFromFieldType (/var/www/private/node_modules/rest-hapi/utilities/joi-mongoose-helper.js:213:27)
    [18:18:32.093] 47383 ERROR    node_modules/rest-hapi/utilities/rest-helper-factory.js:98:16 api —     at /var/www/private/node_modules/rest-hapi/utilities/rest-helper-factory.js:169:46
    [18:18:32.093] 47383 ERROR    node_modules/rest-hapi/utilities/rest-helper-factory.js:98:16 api —     at arrayEach (/var/www/private/node_modules/rest-hapi/node_modules/lodash/index.js:1289:13)
    [18:18:32.093] 47383 ERROR    node_modules/rest-hapi/utilities/rest-helper-factory.js:98:16 api —     at Function.<anonymous> (/var/www/private/node_modules/rest-hapi/node_modules/lodash/index.js:3345:13)
    [18:18:32.093] 47383 ERROR    node_modules/rest-hapi/utilities/rest-helper-factory.js:98:16 api —     at Object.generateListEndpoint (/var/www/private/node_modules/rest-hapi/utilities/rest-helper-factory.js:168:11)
    [18:18:32.093] 47383 ERROR    node_modules/rest-hapi/utilities/rest-helper-factory.js:98:16 api —     at Object.generateRoutes (/var/www/private/node_modules/rest-hapi/utilities/rest-helper-factory.js:51:16)
    [18:18:32.093] 47383 ERROR    node_modules/rest-hapi/utilities/rest-helper-factory.js:98:16 api —     at /var/www/private/node_modules/rest-hapi/rest-hapi.js:92:36
    [18:18:32.093] 47383 ERROR    node_modules/rest-hapi/utilities/rest-helper-factory.js:98:16 api —     at process.nextTick (/var/www/private/node_modules/hapi/node_modules/hoek/lib/index.js:858:22)
    [18:18:32.093] 47383 ERROR    node_modules/rest-hapi/utilities/rest-helper-factory.js:98:16 api —     at _combinedTickCallback (internal/process/next_tick.js:73:7)
    [18:18:32.093] 47383 ERROR    node_modules/rest-hapi/utilities/rest-helper-factory.js:98:16 api —     at process._tickCallback (internal/process/next_tick.js:104:9)
    

    Tell me if you need more details. I'm using the latest version of rest-hapi. Thanks.

    opened by duartealexf 5
  • chore(deps): bump json5 from 2.2.1 to 2.2.3

    chore(deps): bump json5 from 2.2.1 to 2.2.3

    Bumps json5 from 2.2.1 to 2.2.3.

    Release notes

    Sourced from json5's releases.

    v2.2.3

    v2.2.2

    • Fix: Properties with the name __proto__ are added to objects and arrays. (#199) This also fixes a prototype pollution vulnerability reported by Jonathan Gregson! (#295).
    Changelog

    Sourced from json5's changelog.

    v2.2.3 [code, diff]

    v2.2.2 [code, diff]

    • Fix: Properties with the name __proto__ are added to objects and arrays. (#199) This also fixes a prototype pollution vulnerability reported by Jonathan Gregson! (#295).
    Commits
    • c3a7524 2.2.3
    • 94fd06d docs: update CHANGELOG for v2.2.3
    • 3b8cebf docs(security): use GitHub security advisories
    • f0fd9e1 docs: publish a security policy
    • 6a91a05 docs(template): bug -> bug report
    • 14f8cb1 2.2.2
    • 10cc7ca docs: update CHANGELOG for v2.2.2
    • 7774c10 fix: add proto to objects and arrays
    • edde30a Readme: slight tweak to intro
    • 97286f8 Improve example in readme
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
  • chore(deps): bump qs from 6.5.2 to 6.5.3 in /website

    chore(deps): bump qs from 6.5.2 to 6.5.3 in /website

    Bumps qs from 6.5.2 to 6.5.3.

    Changelog

    Sourced from qs's changelog.

    6.5.3

    • [Fix] parse: ignore __proto__ keys (#428)
    • [Fix] utils.merge: avoid a crash with a null target and a truthy non-array source
    • [Fix] correctly parse nested arrays
    • [Fix] stringify: fix a crash with strictNullHandling and a custom filter/serializeDate (#279)
    • [Fix] utils: merge: fix crash when source is a truthy primitive & no options are provided
    • [Fix] when parseArrays is false, properly handle keys ending in []
    • [Fix] fix for an impossible situation: when the formatter is called with a non-string value
    • [Fix] utils.merge: avoid a crash with a null target and an array source
    • [Refactor] utils: reduce observable [[Get]]s
    • [Refactor] use cached Array.isArray
    • [Refactor] stringify: Avoid arr = arr.concat(...), push to the existing instance (#269)
    • [Refactor] parse: only need to reassign the var once
    • [Robustness] stringify: avoid relying on a global undefined (#427)
    • [readme] remove travis badge; add github actions/codecov badges; update URLs
    • [Docs] Clean up license text so it’s properly detected as BSD-3-Clause
    • [Docs] Clarify the need for "arrayLimit" option
    • [meta] fix README.md (#399)
    • [meta] add FUNDING.yml
    • [actions] backport actions from main
    • [Tests] always use String(x) over x.toString()
    • [Tests] remove nonexistent tape option
    • [Dev Deps] backport from main
    Commits
    • 298bfa5 v6.5.3
    • ed0f5dc [Fix] parse: ignore __proto__ keys (#428)
    • 691e739 [Robustness] stringify: avoid relying on a global undefined (#427)
    • 1072d57 [readme] remove travis badge; add github actions/codecov badges; update URLs
    • 12ac1c4 [meta] fix README.md (#399)
    • 0338716 [actions] backport actions from main
    • 5639c20 Clean up license text so it’s properly detected as BSD-3-Clause
    • 51b8a0b add FUNDING.yml
    • 45f6759 [Fix] fix for an impossible situation: when the formatter is called with a no...
    • f814a7f [Dev Deps] backport from main
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
  • chore(deps): bump decode-uri-component from 0.2.0 to 0.2.2 in /website

    chore(deps): bump decode-uri-component from 0.2.0 to 0.2.2 in /website

    Bumps decode-uri-component from 0.2.0 to 0.2.2.

    Release notes

    Sourced from decode-uri-component's releases.

    v0.2.2

    • Prevent overwriting previously decoded tokens 980e0bf

    https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.1...v0.2.2

    v0.2.1

    • Switch to GitHub workflows 76abc93
    • Fix issue where decode throws - fixes #6 746ca5d
    • Update license (#1) 486d7e2
    • Tidelift tasks a650457
    • Meta tweaks 66e1c28

    https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.0...v0.2.1

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
  • chore(deps): bump decode-uri-component from 0.2.0 to 0.2.2

    chore(deps): bump decode-uri-component from 0.2.0 to 0.2.2

    Bumps decode-uri-component from 0.2.0 to 0.2.2.

    Release notes

    Sourced from decode-uri-component's releases.

    v0.2.2

    • Prevent overwriting previously decoded tokens 980e0bf

    https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.1...v0.2.2

    v0.2.1

    • Switch to GitHub workflows 76abc93
    • Fix issue where decode throws - fixes #6 746ca5d
    • Update license (#1) 486d7e2
    • Tidelift tasks a650457
    • Meta tweaks 66e1c28

    https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.0...v0.2.1

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
  • Added support for querying

    Added support for querying "createdAt" date range in listHandler

    Hi @JKHeadley ! 👋

    Firstly, thanks for your work on this project! 🙂

    Regarding the issue #296. Today I used patch-package to patch [email protected] for the project I'm working on.

    Here is the diff that solved my problem:

    diff --git a/node_modules/rest-hapi/utilities/handler-helper.js b/node_modules/rest-hapi/utilities/handler-helper.js
    index e0334e5..a13b2ed 100644
    --- a/node_modules/rest-hapi/utilities/handler-helper.js
    +++ b/node_modules/rest-hapi/utilities/handler-helper.js
    @@ -148,6 +148,23 @@ async function _listHandler(model, request, Log) {
         if (query.$flatten) {
           flatten = true
         }
    +
    +    if ( query.$startDate || query.$endDate ) {
    +      query.createdAt = {}
    +      
    +      if ( query.$startDate ) {
    +        query.createdAt.$gte = new Date( query.$startDate )
    +
    +        delete query.$startDate;
    +      }
    +
    +      if ( query.$endDate ) {
    +        query.createdAt.$lte = new Date( query.$endDate )
    +
    +        delete query.$endDate;
    +      }
    +    }
    +
         delete query.$flatten
         const { $embed } = query
         if (query.$count) {
    diff --git a/node_modules/rest-hapi/utilities/joi-mongoose-helper.js b/node_modules/rest-hapi/utilities/joi-mongoose-helper.js
    index 1a076eb..e230021 100644
    --- a/node_modules/rest-hapi/utilities/joi-mongoose-helper.js
    +++ b/node_modules/rest-hapi/utilities/joi-mongoose-helper.js
    @@ -337,6 +337,8 @@ internals.generateJoiListQueryModel = function(model, logger) {
             .optional()
             .description('An optional field for raw mongoose queries.')
         }
    +    queryModel.$startDate = Joi.date().description( 'The start of the date range.' ).optional()
    +    queryModel.$endDate = Joi.date().description( 'The end of the date range.' ).optional()
         
         _.each(queryableFields, function(fieldName) {
           const joiModel = internals.generateJoiModelFromFieldType(
    

    This issue body was partially generated by patch-package.

    opened by alsabbahy 1
  • CreatedAt search with date range in listHandler

    CreatedAt search with date range in listHandler

    Hello, I've been trying to add the dateRange to rest-hapi querying. And I was wondering if you've had already implemented it or it exists to query with date range for field attribute like "createdAt".

    opened by alsabbahy 3
Releases(v3.2.0)
Owner
Justin Headley
I'm passionate about technologies that unlock the potential in others.
Justin Headley
Noderlang - Erlang node in Node.js

Noderlang allows Node.js programs to easily operate in BEAM environments

devsnek 2 Mar 31, 2022
In-memory filesystem with Node's API

In-memory filesystem with Node's API

Vadim Dalecky 1.4k Jan 4, 2023
The most powerful headless CMS for Node.js — built with GraphQL and React

A scalable platform and CMS to build Node.js applications. schema => ({ GraphQL, AdminUI }) Keystone Next is a preview of the next major release of Ke

KeystoneJS 7.3k Jan 4, 2023
:desktop_computer: Simple and powerful server for Node.js

server.js for Node.js Powerful server for Node.js that just works so you can focus on your awesome project: // Include it and extract some methods for

Francisco Presencia 3.5k Dec 31, 2022
DDD/Clean Architecture inspired boilerplate for Node web APIs

Node API boilerplate An opinionated boilerplate for Node web APIs focused on separation of concerns and scalability. Features Multilayer folder struct

Talysson de Oliveira Cassiano 3k Dec 30, 2022
Elegant and all-inclusive Node.Js web framework based on TypeScript. :rocket:.

https://foalts.org What is Foal? Foal (or FoalTS) is a Node.JS framework for creating web applications. It provides a set of ready-to-use components s

FoalTS 1.7k Jan 4, 2023
wolkenkit is an open-source CQRS and event-sourcing framework based on Node.js, and it supports JavaScript and TypeScript.

wolkenkit wolkenkit is a CQRS and event-sourcing framework based on Node.js. It empowers you to build and run scalable distributed web and cloud servi

the native web 1.1k Dec 26, 2022
nact ⇒ node.js + actors ⇒ your services have never been so µ

nact ⇒ node.js + actors your services have never been so µ Any and all feedback, comments and suggestions are welcome. Please open an issue if you fin

Natalie Cuthbert 1k Dec 28, 2022
A Programming Environment for TypeScript & Node.js built on top of VS Code

Programming Environment for TypeScript & Node.js A battery-included TypeScript framework built on top of Visual Studio Code Website Kretes is a progra

Kretes 677 Dec 11, 2022
Full stack CQRS, DDD, Event Sourcing framework for Node.js

reSolve is a full stack functional JavaScript framework. CQRS - independent Command and Query sides. DDD Aggregate support. Event sourcing - using eve

ReImagined 709 Dec 27, 2022
Clock and task scheduler for node.js applications, providing extensive control of time and callback scheduling in prod and test code

#zeit A node.js clock and scheduler, intended to take place of the global V8 object for manipulation of time and task scheduling which would be handle

David Denton 12 Dec 21, 2021
Micro type-safe wrapper for Node.js AMQP library and RabbitMQ management.

Micro type-safe wrapper for AMQP library and RabbitMQ management Description Section in progress. Getting Started Qupi can be installed by Yarn or NPM

Grzegorz Lenczuk 2 Oct 5, 2021
LoopBack makes it easy to build modern API applications that require complex integrations.

LoopBack makes it easy to build modern applications that require complex integrations. Fast, small, powerful, extensible core Generate real APIs with

StrongLoop and IBM API Connect 4.4k Jan 6, 2023
Actionhero is a realtime multi-transport nodejs API Server with integrated cluster capabilities and delayed tasks

Actionhero The reusable, scalable, and quick node.js API server for stateless and stateful applications NPM | Web Site | Latest Docs | GitHub | Slack

Actionhero 2.3k Dec 29, 2022
Linked Data API for JavaScript

rdflib.js Javascript RDF library for browsers and Node.js. Reads and writes RDF/XML, Turtle and N3; Reads RDFa and JSON-LD Read/Write Linked Data clie

Read-Write Linked Data 527 Jan 1, 2023
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Node Express Template (NET.ts) - a small template project which help you to speed up the process of building RESTful API

Node Express Template (NET.ts) - a small template project which help you to speed up the process of building RESTful API

Przemek Nowicki 26 Jan 4, 2023
Lolis-rest - RESTful API for lolis-api

Lolis REST RESTful + Website for Lolis API. Introduction This is a RESTful API which will be used on Lolis API Website and Wrapper. This API uses Imgu

Waifu.sbs 3 Aug 11, 2022