Skip to content

Commit

Permalink
feat: implement flash
Browse files Browse the repository at this point in the history
  • Loading branch information
DominusKelvin committed Feb 20, 2024
1 parent 6ca6d71 commit dc4430b
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Prettier

on: [push, pull_request]

jobs:
prettier:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- name: Run npm ci
run: npm ci

- name: Run Prettier
run: npx prettier --write .
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
24 changes: 24 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* inertia hook
*
* @description :: A hook definition. Extends Sails by adding shadow routes, implicit actions, and/or initialization logic.
* @docs :: https://sailsjs.com/docs/concepts/extending-sails/hooks
*/
module.exports = function defineFlashHook(sails) {
return {
initialize: async function () {
if (!sails.hooks.session) {
var err = new Error('`flash` hook requires the `session` hook, but the `session` hook is disabled. Please enable both or neither.');
err.code = 'E_HOOKINIT_DEP';
err.name = 'failed requires `session` hook';
return cb(err);
}

sails.after('hook:session:loaded', () => {
const flash = require('connect-flash')
sails.hooks.http.app.use(flash())
})

}
}
}
24 changes: 24 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "sails-flash",
"version": "0.0.0",
"description": "Simple session flash messages for Sails applications",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "Kelvin Omereshone<kelvin@sailscasts.com",
"license": "MIT",
"sails": {
"isHook": true,
"hookName": "flash"
},
"dependencies": {
"connect-flash": "^0.1.1"
}
}

0 comments on commit dc4430b

Please sign in to comment.