Git Product home page Git Product logo

neistion's People

Contributors

talha-t avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

l1lith

neistion's Issues

parametersSchema Accept Strings?

The parametersSchema could accept a string for a class name, then it could match it's classes for one with the same name as that string that way you wouldn't need to import or call the getSandhandsSchema method

Potential Parameter Syntax Improvement

Instead of writing

class RandomParameters {
  @sandhandsProp
  public min!: number;
  @sandhandsProp
  public max!: number;
}

It could be written as

class RandomParameters extends NeistionParameters {
  public min!: number;
  public max!: number;
}

transformParameters & normalizeParameters

TransformParameters:
Allows you to modify your parameters after they are sanitized before they are passed to call. It could accept either the synchronous return, a promise to await to the output, or the call of a provided callback. It would merge the returned value with the existing ones. This could be useful for something like this

transformParameters: (parameters, next) => {
     bcrypt.hash(parameters.password, (error, hash) =>{
          if (error) return next(error)
          next({hash})
     })
}

NormalizeParameters
Almost exactly the same as transformParameters except it would happen before sanitation so you could normalize it before it's sanitized.

normalizeParameters: parameters => ({email: parameters.email.toLowerCase()})

Options for getting the parameters

There should be an option to get the parameters to be sanitized and be passed to the call function. It could accept any one of the following

  • A function for getting them from the express request object (it wouldn't supply the response object)
getParameters: req => req.get('Accept')
getParameters: 'Basic'
  • An object of the above for interpreting multiple parameter sources (example below)
getParameters: {
     auth: 'basic',
     body: 'body'
}

Then the user could fashion their schema based on that object so there wouldn't be any changes necessary to the schema system.

{
    auth: ['username', 'password'],
    body: {age: Number}
}

Verify Function Accept Callback

The verify function should also provide a "authorized" callback like this, because sometimes you will be forcing users to make their code by wrapping their code that only works with callbacks into a promise constructor.

verify: authorized => setTimeout(authorized, 1000)

routeFolder

The routerFolder in the Neiston options will automatically deeply require all files in that folder and their outputs will be treated as routes. This way you can cleanly organize all of your routes without needing to create a huge array of require statements. I recommend Require Directory for this, and you can create behavior with this where the folder names are treated as part of the path.

Verify Function Return String and/or status code

the verify function could be allowed to output Strings for the HTTP response text, or the HTTP status code, like this.

return "Incorrect Password"

or like this, and we could change the default status text mechanism to be based on the status code and automatically overiden by a custom status text.

return 500
return [500, "Database Error"]

Support Fastify

Add a configuration option to use Fastify instead of Express under the hood. One way to achieve this could be to create a new Server class or something to act as a proxy between the Neiston logic and the http framework of choice.

Create Formal Docs

I think when been introduced to this library the amount of information in the readme is overwhelming. I think it could be moved to it's own documentation and the readme made much more simple and comprehensible

TypeScript Options Post-Install Hook

I think there could be a prompt after you install to automatically ask to update the TypeScript config to add the required options so people didn't have to do it manually

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.