SNIPTOR
Version: 0.01
The sniptor allows install code snippet from a gihub project to another project, according to MVP structure or other structure you define! Let's start to reuse code of the more simple way.
Installation
Using NPM
npm install -g -S sniptor
Usage
sniptor <snippet-name>
- snippet-name: The name of the snippet defined in the sniptor manager
Format
For register a new snippet in the sniptor manager it's neccesary define a comment in the top of the file in your snippet project.
Model
// *** model ***const mongoose = ;const Schema = mongooseSchema; const UserSchema = name: type: String unique: true required: "Name is required"lastname: type: String unique: true required: "Lastname is required"email: type: String unique: true required: "Email is required"password: type: String required: "Password is required"createdAt: type: Date default: Datenow; moduleexports = mongoose;
Controller
// *** controller ***const bcrypt = const mongoose = const User = moduleexports { const name email lastname password = reqbody const user = username = name useremail = email userlastname = lastname userpassword = bcrypt user } moduleexports { const email password = reqbody User }
Route
// *** route *** const userController = ;const express = ;const router = express; routerrouter moduleexports = router;
Configuration
For start to use the sniptor, you need a config file (config.json) in your project, it must to have the next fields:
- Paths: Path for components of your app (Controller, Model, Route)
- Project: Framework used (Express, Loopback, etc)
- Pattern: Design pattern using like MVP, MVC, etc.
- Type: Project Type (Webapp, API, WebService, etc)
- Method:
- Add: Insert the snippet directly in your project, it mean, it create a new file for each file type (Model, Controller, Route)
Your config.json must looks like this
{ "paths": { "controller": "controllers", "model": "models", "route": "routes" }, "project": "express", "pattern": "mvc", "type": "API", "method": "add"}
NOTES: In the current version it necessary the next points:
- Have the structure definied in the config.json.
- Create a config.json file in the destination project
Changelogs
To Do
- Install dependencies per project