All Projects → PedramMarandi → ExpressWebpack

PedramMarandi / ExpressWebpack

Licence: MIT license
Webpack and Express backend boilerplate

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects
CSS
56736 projects

Projects that are alternatives of or similar to ExpressWebpack

Respo
A virtual DOM library built with ClojureScript, inspired by React and Reagent.
Stars: ✭ 230 (+1433.33%)
Mutual labels:  mvc
generic-for-core
🏗️ Generic Repository & UOW Pattern For ASP.NET Core
Stars: ✭ 55 (+266.67%)
Mutual labels:  mvc
MicroMVC
Framework:simple、efficient、 easy to project migration, DMVC+C architecture design, only for PHP 7.0+, support nginx+lua mvc architecture
Stars: ✭ 20 (+33.33%)
Mutual labels:  mvc
Leaf
🍁 The easiest way to create clean, simple but powerful web apps and APIs quickly
Stars: ✭ 248 (+1553.33%)
Mutual labels:  mvc
es-mvc
ESMVC 旨在方便 ElasticSearch 的使用,就行访问数据库一样访问ES,提供了方便的 service, mapper 层。底层支持 TransportClient, RestHighLevelClient 。
Stars: ✭ 20 (+33.33%)
Mutual labels:  mvc
mvc-todo
A haskell implementation of todoMVC
Stars: ✭ 26 (+73.33%)
Mutual labels:  mvc
Flexml
🚀基于Litho的Android高性能动态业务容器。
Stars: ✭ 225 (+1400%)
Mutual labels:  mvc
retail-banking
Consumer Banking Application
Stars: ✭ 25 (+66.67%)
Mutual labels:  mvc
Flutter-Wings
This is a structure for flutter developers developed by Invention Technology.
Stars: ✭ 20 (+33.33%)
Mutual labels:  mvc
TeaGo
Simple Go Web Framework
Stars: ✭ 18 (+20%)
Mutual labels:  mvc
Ssh
ssh员工管理系统
Stars: ✭ 252 (+1580%)
Mutual labels:  mvc
fir
Fir. A lightweight PHP MVC Framework.
Stars: ✭ 33 (+120%)
Mutual labels:  mvc
TwistPHP
A fresh, new PHP MVC framework built from the ground up
Stars: ✭ 27 (+80%)
Mutual labels:  mvc
Opentouryo
”Open棟梁”は、長年の.NETアプリケーション開発実績にて蓄積したノウハウに基づき開発した.NET用アプリケーション フレームワークです。 (”OpenTouryo” , is an application framework for .NET which was developed using the accumulated know-how with a long track record in .NET application development.)
Stars: ✭ 233 (+1453.33%)
Mutual labels:  mvc
php-mvc-skeleton
A PHP OOP web application skeleton that uses MVC architectural pattern to create a basic application that contains login and multi language systems and can be used in any web project.
Stars: ✭ 46 (+206.67%)
Mutual labels:  mvc
Quiz App
A repository reflecting the progress made on the "How to Build iOS Apps with Swift, TDD & Clean Architecture" YouTube series, by Caio & Mike.
Stars: ✭ 230 (+1433.33%)
Mutual labels:  mvc
SdvCodeWebsite
Simeon Valev - Personal Blog - Developed on ASP.NET Core MVC - Server-Side Blazor - See README.md file for more information
Stars: ✭ 38 (+153.33%)
Mutual labels:  mvc
velox
The minimal PHP micro-framework.
Stars: ✭ 55 (+266.67%)
Mutual labels:  mvc
MsCoreOne
MsCoreOne is a simple Ecommerce with using many technologies such as .NET 5, Entity Framework Core 5, React 16.13 with modern Clean Architecture, Domain-Driven Design, CQRS, SOLID, Identity Server 4, Blazor. It will focus on resolving the problems always see in the process to develop projects.
Stars: ✭ 77 (+413.33%)
Mutual labels:  mvc
mvc.base
Базовый компонент Битрикс для простой реализации MVC
Stars: ✭ 14 (-6.67%)
Mutual labels:  mvc

Express+Webpack backend boilerplate

An consistence Express framework with power of the Webpack to design an scalable API backend.

  • Structured config files
  • Moongose database
  • Structured models
  • Structured routes
  • Integrated config files with Express config variables
  • Structured controllers and services
  • Mocha testing
  • Build tools and test coverage tools

Installation

To start developing your application, after you cloned the project do

$ npm install
$ npm run-script run-dev

Controllers

In order to develope a consistence and scaleable Express application we've defined different conventions. So, all of the controllers should return a promise. huh? hold on, don't freak out it now, it's sweet you will understand why.

const getUser = async function(username) {
    if(username ==='') 
        throw new Error('Username can\'t be empty');

    return await getUserByUsername(username); // A service
}

Also, you may noticed that there isn't any parameter for getUser function in our controller. We'll pass them with a cool trick. It's cool because you've got rid of (req, res, next) in your controllers.

The logic of our Controllers is driven by Services. The aim of a Service is to developing a reusable code related to models and conrollers. The returned value of your services could be anything.

services/user.js

export function getUser(username) {
    return User.find({username}).exec(); // A promise
}

So, now we should resolve the Promise which is returned by the controllers in the router. Here is our router for getUser function.

router.get('/:username', async function(req, res, next) {
    const data = await userController.getUser(req.params.username);

    return res.json(data);
});

As it mentioned before, all of the controllers will return a promise. You should resolve all of the Controller's promises in each router. However, we made a fake route client to do it for you. You can implement this fake router like below.

router.get('/:username', call(userController.getUser, (req, res, next) => [req.params.username]));

Models

All of your applications' models goes into ./app/models folder.

import mongoos from 'mongoose';
var userSchema = new schema({
    name: {
        type: String,
        require: true
    },
    lastname: {
        type: String,
        required: true
    },
    username: {
        type: String,
        validator: validateUsername,
        msg: "Your username is wrong"
    },
    age: {
        type: Number,
        default: null
    },
    password: String
});

const User = mongoose.model('User', userSchema);

export default User;

You can learn about mongoose from its documentation Mongoose object mondeling.


Configs

All of your configs files should be in ./config folder. ./config/main.js

configs =  Object.assign({
    project: 'ExpressMVC Boilderplate', 
    url: 'localhost', 
    port: process.env.PORT || 3000,  
    api: {
        address: 'http://github.com/api'
    }  
});

const environemnts = {
    production: {
       
    },
    development: {

    }
}[process.env.NODE_ENV || 'development'];

module.exports = Object.assign(project, environemnts);

Your config file will be accessible throughout your application with the Express app.get() method. Moreover, if you have nested level config objects, each level will be accessible with a " . "

    app.get('api.address');

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].