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

egg-coding

v1.3.3

Published

Code generator for egg

Downloads

1

Readme

egg-coding

NPM version build status Test coverage David deps Known Vulnerabilities npm download

Foreword

The tool only builds the underlying code, atomic operations on the database, generates interfaces and some auxiliary code for quick development and does not participate in any business logic.

Dependency Description

Code building tools based on eggjs and sequelize, In order for the code to work, you should use the command egg-coding i to install the necessary dependencies before starting your application.

Code Style

.eslintrc

{
  "extends": "eslint-config-egg",
  "rules": {
    "indent": [2, 4,{ "SwitchCase": 1 }],
    "comma-dangle": ["error", "never"],
    "array-bracket-spacing":["error","never"]
  }
  
}

Installation

Global installation

$ npm i egg-coding -g

Directory Structure

After the build is completed, there will be the following directory structure.

egg-project
├── package.json
├── app.js
├── app
| ├── router.js
│ ├── base_context_class.js (provides a base class for easy extension)
│ ├── controller (control layer)
│ | └── user.js
│ ├── service (business logic layer)
│ | └── user.js
│ ├── router
│ | └── user.js
│ ├── model (database model)
│ | └── user.js
│ ├── rules (parameter verification rules)
│ | └── user.json
│ ├── errors(DIY exception class)
│ | └── client_error.js
│ ├── utils (tool)
│ | └── date_format.js
├── config
| ├── plugin.js (plugin list)
| ├── config.default.js (default configuration)
└── test
    ├── middleware
    | └── response_time.test.js
    └──controller
        └── home.test.js

Development Specifications

  • The model is the same as the database table name, for example, app/model/student.js corresponds to the student table.
  • Each model has a router module in the ${baseDir}/app/router directory and is eventually referenced in ${baseDir}/app/router.js
  • Turn on timestamp and soft delete
  • Parameter validation rules are all placed in the ${baseDir}/app/rules directory
  • All controllers and services inherit the BaseController and BaseService provided by base_context_class
  • Non-code exceptions are defined in errors/client_error.js
  • Time stamp unified formatting
  • Send response data using plugin egg-response
  • Handling exceptions using the plugin egg-error-handler

Testing

The interface provided by default, where order is the table name

'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
Module.exports = app => {
    Const { router, controller } = app;
    Router.resources('/api/v1/order', controller.order);
    Router.post('/api/v1/order/createMany', controller.order.createMany);
    Router.post('/api/v1/order/deleteMany', controller.order.deleteMany);
    Router.post('/api/v1/order/updateMany', controller.order.updateMany);
    Router.post('/api/v1/order/findOne', controller.order.findOne);
    Router.post('/api/v1/order/findByExample', controller.order.findByExample);
};

see more

Rapid development

First step

Initialize a project with egg-init

$ egg-init egg-project --type=simple

Second step

Install the dependency package with egg-coding i

$ egg-coding i

third step

Use egg-coding init to initialize the startup file, default configuration, and enable the plugin

$ egg-coding init

Modify the default configuration as needed

fourth step

Create a database model using egg-coding model

$ egg-coding model model1 model2 model3...

Modify the model as needed, write table fields

Fifth step

Build code with egg-coding curd

$ egg-coding curd -p /api/v1 -r

Modify verification rules as needed

Local debugging

$ npm run dev

The default port is 7834, The whole process will not exceed 10 minutes

Command Parameters

Get help with --help or -h

$ egg-coding -h

Subcommand

$ egg-coding i -h
$ egg-coding init -h
$ egg-coding model -h
$ egg-coding curd -h

Asking questions

Please go to [egg issues] (https://github.com/iamljw/egg-coding/issues) for asynchronous communication.

License

MIT