Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
15 changed files
with
458 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Blog API Docs</title> | ||
<meta charset="utf-8"/> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet"> | ||
|
||
<style> | ||
body { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<redoc spec-url='../schemas/openapi.yaml'></redoc> | ||
<script src="https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js"> </script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
const { Sequelize, DataTypes } = require("sequelize"); | ||
|
||
const sequelize = require('../db'); | ||
const Role = sequelize.define("roles", { | ||
name: { | ||
type: DataTypes.STRING(16), | ||
primaryKey: true, | ||
allowNull: false, | ||
unique: true | ||
}, | ||
description: { | ||
type: DataTypes.TEXT, | ||
}, | ||
}, { | ||
timestamps: false | ||
}); | ||
|
||
sequelize.sync().then(() => { | ||
console.log('Role table created successfully!'); | ||
}).catch((error) => { | ||
console.error('Unable to create table : ', error); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const AccessControl = require('role-acl') | ||
const ac = new AccessControl(); | ||
|
||
ac.grant(['user', 'admin']).condition({Fn:'EQUALS', args: {'requester':'$.owner'}}).execute('update') | ||
.on('article'); | ||
|
||
ac.grant('admin').execute('delete').on('article'); | ||
|
||
exports.update = (requester, authorId) => | ||
ac.can(requester.role).context({requester:requester.ID, owner:authorId}).execute('update').sync().on('article'); | ||
|
||
exports.delete = (requester) => | ||
ac.can(requester.role).execute('delete').sync().on('article'); |
Oops, something went wrong.