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

api-generate-module

v1.2.5

Published

library to produce restfull api based on database schema using Prisma ORM

Downloads

11

Readme

api-generator-module

generator for creating RESTful NodeJS APIs, using ES6, Prisma. The fastest way to get your project up and running using an awesome stack.

Getting started

  • Make sure you have installed on your machine: npm init -y
  • Make typescripts : npm install typescript --save-dev
  • Make install Prisma and @prisma/client: npm install prisma and npm install @prisma/client --save-dev
  • If the database already exists, please do a DB pull using Prisma so that the schema can be updated command: npx prisma init
  • setting file .env envirovment change configuration DATABASE_URL="postgresql://username:password@localhost:port/my-db?schema=public"
  • continue npx prisma db pull or npx prisma generate database
  • continue install several dependencies npm install ts-node --save-dev, npm install @types/node --save-dev
  • final install npm install api-generator-module
  • several configuration npx api-generator-module setup from
  • setup directory and configuration npx api-generate-module generateApi from setup generate file Restfull Api based on schema ORM prisma
  • several configuration tsconfig.json npx api-generator-module generateTsconfig so that you update the tsconfig settings

Running the generated project

Make sure you have node version >= 20 because this project uses native supported ES6 features.

Development

  • Run: postgesql to start the local postgresql
  • Run: npm run dev to run the app (By default the app will run at localhost:3000, you can change this in the config file).

Architecture

Assuming we use user and pet models the generated project will look like this:

 src
│   ├── config
│   │   ├── index.ts
│   ├── controllers
│   │   ├── adminmodule.controller.ts
│   │   ├── app.controller.ts
│   │   ├── attachment.controller.ts
│   │   ├── kabupaten.controller.ts
│   │   ├── kategoripelabuhan.controller.ts
│   │   ├── kategoriperkerasan.controller.ts
│   │   ├── kategoriperlengkapan.controller.ts
│   │   ├── provinsi.controller.ts
│   │   ├── user.controller.ts
│   │   ├── usergroup.controller.ts
│   │   ├── usergroupadminmodule.controller.ts
│   │   ├── usergroupapp.controller.ts
│   ├── dtos
│   │   ├── adminmodule.dto.ts
│   │   ├── app.dto.ts
│   │   ├── attachment.dto.ts
│   │   ├── kabupaten.dto.ts
│   │   ├── kategoripelabuhan.dto.ts
│   │   ├── kategoriperkerasan.dto.ts
│   │   ├── kategoriperlengkapan.dto.ts
│   │   ├── provinsi.dto.ts
│   │   ├── user.dto.ts
│   │   ├── usergroup.dto.ts
│   │   ├── usergroupadminmodule.dto.ts
│   │   ├── usergroupapp.dto.ts
│   ├── exceptions
│   │   ├── HttpException.ts
│   ├── generators
│   │   ├── generatorRestApi.ts
│   │   ├── updateTsconfig.ts
│   ├── http
│   │   ├── adminmodule.http
│   │   ├── app.http
│   │   ├── attachment.http
│   │   ├── kabupaten.http
│   │   ├── kategoripelabuhan.http
│   │   ├── kategoriperkerasan.http
│   │   ├── kategoriperlengkapan.http
│   │   ├── provinsi.http
│   │   ├── user.http
│   │   ├── usergroup.http
│   │   ├── usergroupadminmodule.http
│   │   ├── usergroupapp.http
│   ├── index.ts
│   ├── interfaces
│   │   ├── routes.interface.ts
│   ├── middlewares
│   │   ├── validation.middleware.ts
│   ├── routes
│   │   ├── adminmodule.route.ts
│   │   ├── app.route.ts
│   │   ├── attachment.route.ts
│   │   ├── kabupaten.route.ts
│   │   ├── kategoripelabuhan.route.ts
│   │   ├── kategoriperkerasan.route.ts
│   │   ├── kategoriperlengkapan.route.ts
│   │   ├── provinsi.route.ts
│   │   ├── user.route.ts
│   │   ├── usergroup.route.ts
│   │   ├── usergroupadminmodule.route.ts
│   │   ├── usergroupapp.route.ts
│   ├── setup.ts
├── tsconfig.json

Controller:

HTTP layer, in this instance you can manage express request, response and next. In src/controller are the basic RESTful methods find, findOne, findById, create, update and remove. Because this class is extending from there, you got that solved. You can overwrite extended methods or create custom ones here.

Contributing

Contributors are welcome, please fork and send pull requests! If you find a bug or have any ideas on how to improve this project please submit an issue.

Style guide

Standard - JavaScript Style Guide