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

tartempion

v0.0.7

Published

The web framework for people who like to eat some pie.

Downloads

9

Readme

tartempion

tartempion

Introduction

All the web frameworks out there don't suit my needs.

They're good, really, and I inspired myself from them to build tartempion.

But they either miss the dependency injection, or they're not decoupled enough. Or none of them.

So I built my own framework, based on express and ncore.

Express is well known, it is already a web framework, and tartempion basically wraps express with the dependency injection niceness that ncore provides.

Documentation

The pies concept

In tartempion, there are pies. A pie is a kind. It has its own controller, and its own model. It has only one of them.

There, you grasped the pies concept.

tartempion has no way to know which pies are installed though. So you have to define them somewhere. This somewhere is the pies.json file in the root folder.

This is how it is defined:

{
    "pieName": {
        "path": "pathToPie"
    },
    "anotherPie": {
        "path": "pathToAnother",
        "dependencies": [
            "pieName"
        ]
    }
}

Firstly, it is important to know that all the pies will remain in the pies/ folder.

pieName is the name of the pie. pathToPie is the name of the path, not including pies/. Finally, dependencies defines the dependencies of this pie. This way, you will be able to reach pieName's controller in anotherPie.

As simple as that.

A pie is composed of at least three files: controller.js, model.js and routes.json.

Define some routes

All the pies define the routes they handle. They're defined in the routes.json file. Here is an example of such a file:

{
    "get": [
        { "/pages": "index" },
        { "/pages/:pid": "read" },
        { "/pages/edit/:pid": "editForm" }
    ],
    "post": [
        { "/pages/edit/:pid": "edit" }
    ]
}

As you can see, GET and POST routes are separated. You define the route to use (express.js routes, look here for a more thorough documentation), and the function in the controller.

For example, in the controller.js file of this pie, we will find this:

module.exports = {
    index: function( req, res ) {
    },

    read: function( req, res ) {
    },

    editForm: function( req, res ) {
    },

    edit: function( req, res ) {
    }
};

That's pretty much it about the routes.

Control everything

Just a little while ago, you saw how a controller is defined.

More information:

  • The controller.js file is expected to return an object having all the methods specified in the routes.
  • In these methods, you have access to this.model. This object is the model defined in model.js.
  • If you have defined dependencies in the pies.json file, you will access them using this.pieName.
  • If you have a setup method or an init method, they will be run once when the server will start. (setup first)

Model all the things

Model all the things

The model.js file is where you define the methods usable in the controller.js file.

This is also where you define your model. If you use mongoose, this'd be where the Schemas are defined.

And don't worry

Then, just don't worry! The models are automatically injected in the controllers, the dependencies are injected wherever it's needed! So you don't have to worry. Just code.

Installation

git clone https://github.com/Ralt/tartempion && cd tartempion && npm install

This repository is an example. You can look around to see how it's working.

Roadmap

  • Add middlewares support ✓
  • Add views helpers support ✓
  • Add database support ✓
  • Add a more thorough config.json file ✓
  • Create a useful sample app ✓ (done)
  • Refactor the core.js file ✓
  • Create a module pushable to npm ✓
  • Push to npm ∞
  • Create a CLI interface to use tartempion globally ✕
  • Create a mocha interface to test the pies (individually or all together) ✕
  • Create tests for tartempion ✕
  • Update the documentation ✕

License

The MIT License (MIT)

Copyright (c) 2012 Florian Margaine

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.