npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

organiser

v1.0.0

Published

An organic web framework for organized web servers.

Downloads

20

Readme

v1.0.0 - Beta Beta stage - Not safe for production StandardJS GitHub license Stars on Github

An organic web framework for organized web servers.

upcoming features - known issues - send suggestion


Organiser is a web framework focused on provinding the best developing and maintenance experience, benefiting from Ecmascript's new definitions, with support from Babel.

Our goal is having an organized and organic server. But what does that mean?

It means that you can bring complex highly scalable systems to life, with easy maintaining, without having to learn hard syntaxes. It is organized because of its well-known syntax, used in Spring Boot, for example, and it is organic because Organise makes sense: it is just like telling the server what it should do, in almost natural-like language.

Organiser works with inversion of control principles, creating one of the most powerful environments for MVC development in Node.js, for example. Just tell what you want through its decorators and let the magic happen.


⚠️

Organiser is in beta stage. It's not recommended for production usage yet.


  1. Install
  2. Examples
  3. Events
  4. Modules
  5. @Arguments - Inversion of Control
  6. Documentation
  7. Team
  8. License

Install

This is a Node.js module. Therefore, beforehand, you need to download and install Node.js. Node.js 6.0.0 or higher is required.

Assuming that you have already used the npm init command, run:

$ npm install organiser --save

Examples

A server with only a GET endpoint at localhost:3000 (default) that shows Hello, world! as plain text.

import { Server, GET, Response, MediaType } from 'organiser'

class HelloWorld {
  @GET
  async foo () {
    return Response.ok('Hello, world!', MediaType.TEXT_PLAIN).build()
  }
}

const server = new Server() // creates a new instance of Organise
server.routes(HelloWorld) // register controllers, passing their classes by reference
server.boot() // start server

Virtual personal agenda, with notes and contacts, using NeDB.

import { Server, Modules } from 'organiser'
import { NotesController } from './controllers/notes'
import { ContactsController } from './controllers/contacts'

const server = new Server({
  name: 'Agenda',
  internal: {
    debug: true
  }
})

server.modules(Modules.bodyParser())
server.routes(NotesController, ContactsController)
server.boot()

Events

Work in progress...

Modules

You can use how many modules, before and/or after a request, as you wish. We support context and connect middlewares/modules styles.

Modules defined in server.modules(module1, module2, module3, ...) will be executed before every controller, in a sequence order (module1 → module2 → module3 → ... → controller). When calling server.modules() with parameters, it returns an object containing a function called after(...), that lets you register modules the same way, but they will run after every controler. Calling it without parameters will return an object with before(...) and after(...).

When you register routes through server.routes(ControllerClass1, ControllerClass2, ControllerClass3, ...), it also returns an object with before(...) and after, letting you register modules only for the routes passed as parameters.

Using @ModuleBefore(module1, module2, module3, ...) and @ModuleAfter(module4, module5, module6, ...) above a class or function reproduces the same behavior.

Built-in modules
Example
import { Server, GET, Response, Modules, ModulesBefore, ModulesAfter } from 'organiser'

function hello (context) {
  return new Promise((resolve) => {
    console.log('hello executed!')
    console.log('You can add properties to the request context and use their values in other modules!')
    context.bye = 'See you!'
    context.luckNumber = Math.floor(Math.random() * 10) + 1
    resolve()
  })
}

function bye (context) {
  return new Promise((resolve) => {
    console.log('bye executed!')
    context.expectedResponse = Response.ok({ bye: context.bye, luckNumber: context.luckNumber }).build()
    resolve()
  })
}

@ModulesBefore(hello)
class Foo {
  @GET
  @ModulesAfter(bye)
  async bar () {
    return Response.ok({ foobar: true }).build()
  }
}

const server = new Server()
server.modules(Modules.bodyParser())
server.routes(Foo).before(
  () => console.log('First module executed!'),
  () => console.log(`Keep going...`)
).after(
  () => console.log('last module executed!')
)
server.boot()

Work in progress...

@Arguments - Inversion of Control

Through the Arguments decorator, you can inject dependencies anywhere, anytime. Just use the class of the desired instance and Organised will take care of the rest.

When used above classes, the respective class' constructor will be called with the parameters passed through the Arguments decorator.

When used above functions, it only supports one parameters: the data model (object containing properties that Organiser should retrieve). The data model supports inner models (functions returning objects).

Example
import { Arguments, Path, PUT, Types } from 'organiser'
import ContactsService from '../services/ContactsService'
import Contact from '../models/Contact'
import logEntity from '../utils/exampleLog'

@Arguments(ContactsService, logEntity)
@Path('contacts')
export class ContactsController {

  constructor (service, entityLogger) {
    this.service = service
    this.logger = entityLogger
  }

  @POST
  @Path('{userId}') // => "/contacts/123"
  @Arguments({
    userId: Types.INTEGER,
    contact: Contact
  })
  async create ({ userId, contact }) { // userId = 123, contact = { ... }
    contact.ownerId = userId
    return Response
            .status(201) // Created
            .entity(this.logger(await this.service.create(contact)))
            .build()
  }

}
// '../models/Contact'

import { Types } from 'organiser'

export default function Contact () {
  return {
    id: Types.INTEGER,
    name: Types.STRING,
    email: Types.STRING,
    ownerId: Types.INTEGER
  }
}
// '../utils/exampleLog'

export default function (entity) {
  console.log(entity)
  return entity
}
  • Contact is a function that returns an object. This is how you define a model in Organise.
  • ContactsService is just a regular class, used as a service. You can also use Arguments to inject parameters in its constructor (calling other services instances, for example).

Read more about how the Arguments decorator works with functions here.

Documentation

Available decorators
  • ✔️ Arguments (accept parameters)
  • ✔️ Path (accept parameters)
  • ✔️ ModulesAfter (accept parameters)
  • ✔️ ModulesBefore (accept parameters)
  • ✔️ GET (functions only)
  • ✔️ HEAD (functions only)
  • ✔️ POST (functions only)
  • ✔️ PUT (functions only)
  • ✔️ DELETE (functions only)
  • ✔️ OPTIONS (functions only)
  • ✔️ TRACE (functions only)
  • ✔️ PATCH (functions only)
Model property types
  • ️️✔️ Types.UUID: 'uuid'
  • ✔️ Types.STRING: 'string'
  • ✔️ Types.BOOLEAN: 'boolean'
  • ✔️ Types.INTEGER: 'integer'
  • 🚧 Types.DOUBLE: 'double'
  • 🚧 Types.FLOAT: 'float'
  • 🚧 Types.DATE: 'date'
  • 🚧 Types.FILE: 'file'
  • ✔️ Types.CLIENT_REQUEST: 'clientRequest'
  • ✔️ Types.SERVER_RESPONSE: 'serverResponse'

It is encouraged the usage of Types.* instead of their respective string version, for versioning purposes.

Data models

Work in progress...


Team

Created and developed by Arthur Arioli Bergamaschi, supervised by the JavaScript Advanced Core (NAJaS - Núcleo Avançado de JavaScript) at Fatec Taquaritinga.


License

Licensed under MIT.


Disclaimer: Organiser is still a work in progress. Methods and behavior can change along the way.