Giter Club home page Giter Club logo

mean-boilerplate's Introduction

this project ahs moved too MEA7N

MeanStack Boilerplate with angular 6

Description

This app is a quick start for Mean applications. it currently is setup with a service worker so it is progressive. has its own css lib. and has a mini guide to setting up state.

preview

install

after cloning npm i in the root directory. (this also builds the dist folder for the first time)

contents

prerequisites

  • nodeJs installed
  • angular cli installed globally
  • mongoDb installed locally or a mlab account(for development you can simply use their free option)

getting started

Use git clone https://github.com/lloydst/mean-boilerplate.git ./ to clone the project in the current directory to change it to a different directory simply add the directory name after the /.

install

after cloning go into the project root (where the package.json is located) and use npm i. This will build the dist folder for the first time after installing all of the packages.

for the db setup refer too database

styling

this project has been setup with scss support and has a basic style library. to make changes simply type: grunt watch in the project root and it start watching the scss files for changes in the styleguide/scss directory.

sources:

This project was generated with Angular CLI version 1.5.0. And the express-generator version 4.15.5. And bumbed to Angular 6.

Development server

Run ng serve for a dev (frontend)server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files but wont show data from api endpoints. Run node server.js for your express server http://localhost:3000/

Because the node server also watches the dist folder, you could use nodemon server.js instead. if you then make changes to your angular app simply type ng build in another window and the server will automaticly restart.

Code scaffolding (angular cli)

Run ng generate component componentname to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module. if you decide to add state to your application as well refer too the state section for ngrx related scaffolding.

structure

server contains all server related stuff.

  • "e2e" Test related stuff. (for angular only )
  • "src" your angular project.
  • "dist" the build version of your angular app (compressed)
  • node

database

to connect to a database simply add a .env file in the root and type MONGOURI = mongodb://localhost:27017/whatever_you_want_the_database_to_be_called

optional

state

adding ngrx (state) to your app

npm install @ngrx/schematics --save-dev ng config cli.defaultCollection @ngrx/schematics

install ngrx packages

npm install @ngrx/store @ngrx/effects @ngrx/store-devtools @ngrx/router-store –save npm install @ngrx/schematics --save-dev ng config cli.defaultCollection @ngrx/schematics the last command sets up your angular cli so that you can use ngrx schematics

generate store folder in app folder with root reducer

ng generate store State --root --statePath store/reducers --module app.module.ts after this command you will need to fix the following line in app.module import { environment } from ‘../../../environments/environment’; unfortunatly the ngrx schematics arent the smartest thing

generate

auth is just a place holder

action

action definitions ng generate action store/actions/auth --actions index.ts

reducer

state, initial state, state functions ng generate reducer store/reducers/auth --reducers index.ts

effects

http request for instance ng generate effect store/effects/auth --module app.module --root true needs the following imports :

import { Injectable } from '@angular/core';

import { Actions, Effect, ofType } from '@ngrx/effects';

import { Observable } from 'rxjs';

import { HttpClient } from '@angular/common/http';

import * as authActions from '../actions/auth.actions'; (this one has to be changed ofc)

import { Action } from '@ngrx/store';

import { switchMap, map } from 'rxjs/operators';

final

the most basic structure you should see is:

(...) src

  • app
    • store
      • actions
        • auth.actions.ts
      • effects
        • name.effects.ts
      • reducers
        • index.ts
        • name.reducer.ts

(...)

mean-boilerplate's People

Contributors

angular-cli avatar lloydst avatar oracleruiz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

oracleruiz pmh32

mean-boilerplate's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.