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

haykal

v0.1.6

Published

Typescript MVC framework

Downloads

9

Readme

Haykal

Haykal is a typescript MVC framework, originally designed for generating web application backends, it is flexible enough to work with any project. Haykal generates a loosely coupled project, and is able to generate component templates.

Haykal uses Express and Objection/Knex by default, but it's decoupled and can be replaced by other equivalent libraries and frameworks. Support for other libraries will come after.

How to use

haykal is a cli tool, install it through

npm i -g haykal current available commands are:

  • initialize a new project: haykal init <project-name> creates a new folder in the current directory, installs dependencies and generates the folders and files and creates the project boilerplate

  • generate components: haykal gen [options] <component> type of resource can chosen through these options: - -a: resource // generates all components with CRUD methods for the controller and routes - -c: controller - -r: router - -i: model interface - -m: model implementation - -mi: migration

    and optionally attributes options --attributes (e.g : --attributes id:primary name:string age:number) currently supported types: string, number, date, boolean and primary (incremental id) if you do not enter the attributes option you're able to add them after running the command. if you're generating a component without attributes (e.g a router or controller), just hit enter after the command.

Project Structure:

 /src
    - /controllers
        - <controller classes>
    - /dependency
        - index.ts
        - config.ts
    - /models
        - /interface
            - base.ts
            - <model interfaces>
        - /<implementation> (e.g objection)
            - base.ts
            - <model implementation classes>
    - /tests
        - <test files>
    - /services
        - <service classes>
    - /application
        - /<implementation> (e.g express)
            - index.ts
            - error.ts
            - /api
                - /v1
                    - index.ts
                    - <routes>
                - index.ts
    - /db
        - /<implementation> (e.g objection)
            - index.ts
    - /exceptions
        - index.ts
  • Controllers: Unlike other MVC frameworks, controllers are not the HTTP route handlers, those are inside route files. Controllers are the logic side of Models in the usual MVC pattern, and they handle only business rules.
  • Models: In practice, repositories, they define a standard way to interface with your chosen data store. interfaces hold the standard method definitions, while implementation folders contain the ORM/SQL/HttpRequests required to fulfill the implementation.
    • interface: defines a common interface to be implemented by model repositories.
    • implementation: the repository implementation classes, if using an ORM, defines the ORM Model here and a repository class that implements the interface methods using said ORM.
  • Dependency:
    • index.ts: initializes dependency injection and exports instances of classes and models.
    • config.ts: defines a central place to read environment variable and define default values for them.
  • Tests: includes all test files.
  • Application: handles all application's access implementations, could be a HTTP server, a CLI tool, etc the following example is of the Express implementation.
    • express:
      • index.ts: bootstraps the entire application.
      • error.ts: generic express error handler.
      • api: index.ts: handles registering all api routes, reads every folder and imports it as router for use(e.g "/v1"). v1: the default api version. - index.ts: handles registering all routers within its directory.
  • DB: defines DB access configuration files.
    • databaseImplementation: the config for the chosen implementation.
  • Exceptions:
    • index.ts: Holds exception and error classes.