Giter Club home page Giter Club logo

aqua-sql's Introduction

Aqua SQL

A website and user system starter based on the fabulous Aqua.

The code has been modified to persist data to an SQL datasource via Sequelize

All feedback is welcome.

Finally a huge thank you to Reza Akhavan for Aqua.

Build Status Dependency Status devDependency Status

Features

  • Universal front-end website
    • Basic web pages ready to customize
    • Contact page with form to email
    • Account sign-up page
    • Login pages including forgot and reset password
  • My account area
    • Stub dashboard ready to customize
    • Settings screen to update contact info and login credentials
  • Admin back office
    • Stub dashboard ready to customize
    • Manage accounts, admins, groups and users
    • Use groups (like departments) for shared permissions
    • Granular permissions override group permissions

Live demo

url username password
https://getaqua.herokuapp.com/ root root

Technology

Server side, Aqua is built with the hapi framework. We're using Postgres as a data store.

The front-end is built with React. We use Redux as our state container. Client side routing is done with React Router. We're using Gulp for the build system.

We use bcrypt for hashing secrets. If you have issues during installation related to bcrypt then refer to this wiki page.

API only

If you don't use React and/or would rather bring your own front-end, checkout Frame. It's just the HTTP API parts of Aqua.

Live demo

url username password
https://aqua-sql.herokuapp.com/ root root

Requirements

You need Node.js installed and you'll need Postgres installed and running.

We use bcrypt for hashing secrets. If you have issues during installation related to bcrypt then refer to this wiki page.

Installation

$ git clone [email protected]:jimlowrey/aqua-sql.git
$ cd aqua-sql
$ npm install

Paste the following into PSQL console. The passwords will both be test.

CREATE ROLE aqua LOGIN
  ENCRYPTED PASSWORD 'md5febfd8a9585cddd9e4577010f18a0a5c'
  NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE NOREPLICATION CONNECTION LIMIT 100;

CREATE DATABASE aqua
  WITH OWNER = aqua
       ENCODING = 'UTF8'
       TABLESPACE = pg_default
       LC_COLLATE = 'C'
       LC_CTYPE = 'C'
       CONNECTION LIMIT = -1;

CREATE ROLE aqua_test LOGIN
  ENCRYPTED PASSWORD 'md512d23bb09f295a82e5a316755dfdc0ca'
  NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE NOREPLICATION CONNECTION LIMIT 100;

CREATE DATABASE aqua_test
  WITH OWNER = aqua_test
       ENCODING = 'UTF8'
       TABLESPACE = pg_default
       LC_COLLATE = 'C'
       LC_CTYPE = 'C'
       CONNECTION LIMIT = -1;

Configuration

Simply edit config.js. The configuration uses confidence which makes it easy to manage configuration settings across environments. Don't store secrets in this file or commit them to your repository.

Instead, access secrets via environment variables. We use dotenv to help make setting local environment variables easy (not to be used in production).

Simply copy .env-sample to .env and edit as needed. Don't commit .env to your repository.

First time setup

WARNING: This will clear all data in the following SQL Tables if they exist: accounts, admin_groups, admins, auth_attempts, sessions, statuses, and users.

$ npm run first-time-setup

# > [email protected] first-time-setup /home/jedireza/projects/aqua
# > node first-time-setup.js

# Root user email: [email protected]
# Root user password:
# ...
# Setup complete.

Running the app

$ npm start

# > [email protected] start /Users/jedireza/projects/aqua
# > gulp react && gulp

# [23:41:44] Using gulpfile ~/projects/aqua/gulpfile.js
# ...

Now you should be able to point your browser to http://127.0.0.1:8000/ and see the welcome page.

nodemon watches for changes in server code and restarts the app automatically. gulp and webpack watch the front-end files and re-build those automatically too.

We also pass the --inspect flag to Node so you have a debugger available. Watch the output of $ npm start and look for the debugging URL and open it in Chrome. It looks something like this:

chrome-devtools://devtools/remote/serve_file/@62cd277117e6f8ec53e31b1be58290a6f7ab42ef/inspector.html?experiments=true&v8only=true&ws=localhost:9229/node

Running in production

$ node server.js

Unlike $ npm start this doesn't watch for file changes. Also be sure to set these environment variables in your production environment:

  • NODE_ENV=production - This is important for many different optimizations, both server-side and with the front-end build files.
  • NPM_CONFIG_PRODUCTION=false - This tells $ npm install to not skip installing devDependencies, which we need to build the front-end files.

Have a question?

Any issues or questions (no matter how basic), open an issue. Please take the initiative to read relevant documentation and be proactive with debugging.

Want to contribute?

Contributions are welcome. If you're changing something non-trivial, you may want to submit an issue before creating a large pull request.

Running tests

Lab is part of the hapi ecosystem and what we use to write all of our tests.

Tests have been adapted from the original tests to suit Sequelize and Hapi-Sequelize. Some of the originals no longer apply. Some more need to be added.

$ npm test

# > [email protected] test /Users/jedireza/projects/aqua
# > lab -t 100 -S -T ./test/lab/transform -L --lint-options '{"extensions":[".js",".jsx"]}' ./test/lab/client-before.js ./test/client/ ./test/lab/client-after.js ./test/server/ ./test/lab/server-after.js ./test/misc/

#  ..................................................
#  ..................................................
#  ..................................................
#  ..................................................
#  ..................................................
#  ..................................................
#  ..................................................
#  ..................................................
#  ..................................................
#  ..................................................
#  ..................................................
#  ..................................................
#  ..................................................
#  ..................................................
#  ..................................................
#  ..................................................
#  ..................................................
#  ...............

# 865 tests complete
# Test duration: 6382 ms
# No global variable leaks detected
# Coverage: 96.47%
# Linting results: No issues

Targeted tests

If you'd like to run a specific test or subset of tests you can use the test-client and test-server scripts included in the package.json file.

You specificy the path(s) via the TEST_TARGET environment variable like:

$ TEST_TARGET=test/server/web/main.js npm run test-server

# or

$ TEST_TARGET=test/client/actions/api.js npm run test-client

License

MIT

Don't forget

What you build with Aqua is more important than Aqua.

aqua-sql's People

Contributors

alex-dixon avatar brnomendes avatar henriquesa avatar ivanph avatar jedireza avatar jimlowrey avatar justingreenberg avatar ldesplat avatar mistereo avatar rstormsf avatar socksrust avatar vkvam avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.