Skip to content

Instantly share code, notes, and snippets.

@imhashir
imhashir / MainNav.js
Created April 26, 2020 12:31
Implementing Custom User/Permissions/Roles System with React, Serverless Lambda & MySQL
export default {
items: [
{
name: 'Dashboard',
url: '/dashboard',
icon: 'icon-speedometer',
},
{
name: 'Departments',
url: '/departments',
import React from 'react';
// ....
// Import all pages here
// ....
const routes = [
{ path: '/dashboard', name: 'Dashboard', component: Dashboard },
// db/index.js
const mysql = require('serverless-mysql')({
config: {
host : process.env.DB_ENDPOINT,
database : process.env.DB_NAME,
user : process.env.DB_USER,
password : process.env.DB_PASS
}
});
@imhashir
imhashir / serverless.yml
Last active April 26, 2020 11:47
Implementing Custom User/Permissions/Roles System with React, Serverless Lambda & MySQL
service: your-service-name
plugins:
- serverless-dotenv-plugin
- serverless-offline
- serverless-plugin-split-stacks
custom:
dotenv:
basePath: environments/
@imhashir
imhashir / schema.sql
Last active April 26, 2020 11:47
Implementing Custom User/Permissions/Roles System with React, Serverless Lambda & MySQL
CREATE TABLE user (
id int NOT NULL AUTO_INCREMENT,
name varchar(128) NOT NULL,
email varchar(255) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (id)
);
CREATE TABLE role (
id int NOT NULL AUTO_INCREMENT,