First create a directory for your application, where the source code will be:
mkdir -p notes cd notesCopied!
Create PostgreSQL user (with the same name as your logged on Linux user, so no password needed), and the database "db_app":
echo "create user $(whoami); create database db_app with owner=$(whoami); grant all on database db_app to $(whoami); \q" | sudo -u postgres psqlCopied!
Create a database configuration file to describe your PostgreSQL database above:
echo "user=$(whoami) dbname=db_app" > db_appCopied!
Create database objects we'll need - users table for application users, and notes table to hold their notes:
echo "create table if not exists notes (dateOf timestamp, noteId bigserial primary key, userId bigint, note varchar(1000)); create table if not exists users (userId bigserial primary key, email varchar(100), hashed_pwd varchar(100), verified smallint, verify_token varchar(30), session varchar(100)); create unique index if not exists users1 on users (email);" | psql -d db_appCopied!
Create application "notes" owned by your Linux user:
sudo mgrg -i -u $(whoami) notesCopied!
This executes before any other handler in an application, making sure all requests are authorized, file "before-handler.gliim":
vi before-handler.gliimCopied!
Copy and paste:
before-handler set-param displayed_logout = false, is_logged_in = false call-handler "/session/check" end-before-handlerCopied!
- Signup users, login, logout
This is a generic session management web service that handles user creation, verification, login and logout. Create file "session.gliim":