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

draig-car

v2.0.2

Published

Database REST API interactive generator CLI and REPL OpenAPI3 based JS generator with interactive ORM/ODM REPL

Downloads

12

Readme

DRAIG (CLI-and-REPL)

This is the Command Line Interpreter and Read-Eval-Print Loop for DRAIG (Database REST-API Interactive Generator).

Requisites

You need a few tools to develop, generate and test your microservices:

  • Operating System: GNU/Linux or Windows (working with some caveats). macOS should work but it's not tested and it would need some more work
  • NodeJS v14 or higher
  • JDK/8 or higher to be able to generate code
  • DRAIG (required). You can also use openapi-codegen or swagger-codegen (not tested) but some tweaks will be needed to the configuration files.
  • Working installation of docker (GNU/Linux, macOS) or Docker Desktop (Windows) is also required if you want to use MySQL, PostgreSQL or OracleDB as the DB backend (sqlite3 does not require any docker installation).

Installation

Use npm -g install draig-car

For development work on draig-car itself, clone the GitLab repo and do an npm -g install or yarn -g install to have a local working copy.

Getting started

Choose one of two options:

  1. Start a project with an existing OpenAPI3 contract. You will need to create the configuration file draig.yaml.

  2. Create a project without an OpenAPI3 contract, that will be newly created with matching configuration.

For both options, you should use the following cli command:

> mkdir <project> && cd $_ # Optional
> draig init <project> <port> <mysql|sqlite3|pg|oracledb> <dbname>

If the API definition <project>.yaml already exists it will not be overwritten and it will be used as the generation source for the microservice.

The config file (and the <project>.yaml file, if it didn't existed) will be created in the directory where the command is issued. You should create your own project directory (if required).

Now you can tweak or complete your API definition using any YAML editor. Also, you can use the draig REPL to inspect and complete the API definition, with is automatically saved after each change.

Initial DB creation

If you are using mysql, oracledb or pg database clients, draig-car need to create a proper container for the database and to create the database user with the required privileges. To do so, issue the following command:

> draig run dbstart
> draig run dbreset

If the image is not previously downloaded, it will take a little longer. Please, be patient.

Code generation

Just sit on your <project> dir so you can generate the project code using the following command:

> draig generate

This command not only generates the code, but also creates and populates the database with a generated seed based in faker (if seedGen.__useFaker is enabled).

Running the code

If the generation is successfull and the DB is created and populated, the API could be served inmediatelly.

> draig serve