https://github.com/emmanuelnwankwo/mean-angularjs
Single Page Application
https://github.com/emmanuelnwankwo/mean-angularjs
angular1 angularjs api express jwt mean-stack node single-page-app
Last synced: 4 months ago
JSON representation
Single Page Application
- Host: GitHub
- URL: https://github.com/emmanuelnwankwo/mean-angularjs
- Owner: emmanuelnwankwo
- Created: 2017-11-16T12:09:28.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-01-31T22:17:43.000Z (over 3 years ago)
- Last Synced: 2025-02-25T14:51:55.771Z (over 1 year ago)
- Topics: angular1, angularjs, api, express, jwt, mean-stack, node, single-page-app
- Language: HTML
- Homepage:
- Size: 2.13 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MEAN-angularjs
## Single Page Application
This is my first SPA test-project using MEAN-STACK components (angularjs-1.6.6 precisely). The backend consist of
`API` with `jsonwebtoken`
```
var bodyParser = require('body-parser');
var User = require('../models/user');
var Student = require('../models/student');
var jwt = require('jsonwebtoken');
var config = require('../../config');
// Secret for creating tokens
var hiddenSecret = config.secret;
continue on app/routes/api.js
```
**User Schema**
```
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var bcrypt = require('bcrypt-nodejs');
// user schema
var UserSchema = new Schema({
firstname: String,
lastname: String,
username: { type: String, required: true, index: { unique: true }},
password: { type: String, required: true, select: false },
address: String,
city: String,
state: String,
dob: String,
gender: String,
mobile: String,
tclass: String
});
// hash the password before the user is saved
UserSchema.pre('save', function(next) {
var user = this;
// hash the password only if the password has been changed or user is new
if (!user.isModified('password')) return next();
// generate the hash
bcrypt.hash(user.password, null, null, function(err, hash) {
if (err) return next(err);
// change the password to the hashed version
user.password = hash;
next();
});
});
// method to compare a given password with the database hash
UserSchema.methods.comparePassword = function(password) {
var user = this;
return bcrypt.compareSync(password, user.password);
};
module.exports = mongoose.model('User', UserSchema);
```
**Student Schema**
```
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
// Student schema
var StudentSchema = new Schema ({
firstname: String,
lastname: String,
gender: String,
dob: String,
level: String,
mobile: Number,
city: String,
parentsname: String,
parentsnumber: Number,
state: String,
address: String
});
module.exports = mongoose.model('Student', StudentSchema);
```
## Installation
1. Download the repository
2. Install npm modules: `npm install`
3. Start up the server: `node server.js`
4. View in browser at http://localhost:3000
With lots of work on both the backend and frontend view, I will call it a shot here to move on with latest [angular](http://angular.io/) (v5.x as of the time this was written).
**Note:** The frontend design view was not awesomely designed as it was not the focus of this project, however I used some bootstrap and fontawesome to tweaks some views.
### Known issues include,
- Unable to delete user(staff) profile from the frontend though it works perfectly from the backend
- You may experience browser freezing while trying to get a user profile details when logged-in
*This project is still open for review and corrections*