GithubHelp home page GithubHelp logo

mailer's Introduction

Mailer

Build Status

This is simple SPA app using the following technologies:

preview

Example

The deploy example is located on Heroku.

Access (email and password)

Login details specified in the fixtures: fixtures/models/users.js. For example: email [email protected], pw mike

Quick start

  1. Start mongodb:
mongod --bind_ip "127.0.0.1" --dbpath=/home/youruser/mongodb/mongo.db

The server uses mongoose to work with mongodb. The config files is located here:config/.

  1. Install all dependencies using npm:
npm i
  1. Load fixtures (fixtures/models/) into db:
npm run db:fixtures
  1. Start nodejs server:
npm run server:dev
  1. Build project:
npm run build:watch

The built files (js, css, img) are copied to here: server/public/

  1. Open browser: http://localhost:3000/

Tasks

  • build:clean - clean the built files from server/public/;
  • build:dev - build project for development;
  • build:prod - build project for production;
  • build:watch - build project for development and starts proxy server for watching changes;
  • server:dev - start nodejs server with development config;
  • server:prod - start nodejs server with production config;
  • server:watch - start nodejs server via nodemon, so you need to install this module globally;
  • db:fixtures: load fixtures (fixtures/models/) to db;
  • test:server - run tests for server api
  • test:client - run unit tests

API

The server has API routes for work with data application (login, logout, getting from db).If you passed to another url (not API), then the server will always return template server/modules/spa/templates/index.jade (because It's SPA).All API routes require authorization.If you are logged in then the server will respond 200, otherwise 401. For authenticate you need enable automatic sending cookies from js. See example below for fetch.

The server has following API routes:

  • POST /api/login - authorizes user.

Login and password for users are located here: fixtures/models/users.js. Note you need passed user's data into body of request using urlencoded. Note you need enable automatic sending cookies from js for authenticate. For example for fetch:

fetch("http://localhost:3000/api/login", {
  method: "POST",  
  headers: {  
    "Content-type": "application/x-www-form-urlencoded; charset=UTF-8"  
  },  
  credentials: "same-origin",
  body: "[email protected]&password=mike"
});

For example for $http:

let access = { email: "[email protected]", password: "mike" };

$http.post("http://localhost:3000/login", $httpParamSerializerJQLike(access), {
  headers: {
    "Content-Type": "application/x-www-form-urlencoded"
  }
}).then(res => res.data);
  • POST /api/logout - logout for the current session.

For example for fetch:

fetch("http://localhost:3000/api/logout", {
  method: "POST",  
  credentials: "same-origin"
});
  • GET /api/users?offset=5&limit=10 - get 10 users from 5. Model see here: server/modules/users/models/user.js.

  • GET /api/users/:id - get user by id

  • DELETE /api/users/:id - remove user by id

  • GET /api/count_letters - get json with the number of letters in mailboxes. Example body of response: {"c7422f8013527a1c20d8dd6d":38,"af1cd994dfcb9286c394d142":8,"4a25fb4d024699c2d82bbd0a":4}

  • GET /api/letters/:id - get letter by id

  • POST /api/letters/ - create new letter. Model see here: server/modules/letters/models/letter.js.

  • DELETE /api/letters/:id - remove letter by id

  • DELETE /api/letters - remove more then one letter. Example the body of request: {"deleteId":["4a25fb4d024699c2d82bbd0a","4a25fb4d024699c2d82bbd0b"]}

  • GET /api/mailboxes - get all mailboxes. Model see here: server/modules/mailboxes/models/mailbox.js.

  • GET /api/mailboxes/:id/letters - get letters by mailbox id

  • DELETE /api/mailboxes/:id/letters - remove all letters by mailbox id

License

MIT

mailer's People

Contributors

selkinvitaly avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.