Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pazuzu111/xpress-shotgun
https://github.com/pazuzu111/xpress-shotgun
crud dependecies express homebrew module mvc npm sh
Last synced: 26 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/pazuzu111/xpress-shotgun
- Owner: pazuzu111
- Created: 2017-12-12T19:54:21.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2017-12-24T22:49:09.000Z (almost 7 years ago)
- Last Synced: 2024-09-29T07:22:36.654Z (about 1 month ago)
- Topics: crud, dependecies, express, homebrew, module, mvc, npm, sh
- Homepage: https://www.npmjs.com/package/xpress-shotgun
- Size: 46.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
![shotgunlogo1](https://user-images.githubusercontent.com/31411569/34085495-c7f82124-e35f-11e7-97de-f0a36cd80ad2.png)
![ezgif com-video-to-gif 1](https://user-images.githubusercontent.com/31411569/34190621-cb417db0-e50f-11e7-8077-d0b36d3e706c.gif)# xpress-shotgun
xpress-shotgun is a npm module that shotguns an express MVC to your specified directory
* a directory will be made along with the model, with methods and sql commands already embedded
the controller & the views
* you will have a full crud express app, all you have to do is create a database, a node server,
& fll out views to your liking
* shotgun also takes care of the npm init & installs ejs(viewengine) and pg-promise(more info below)
# before use INSTALL bashBash version can be queried with the --version flag:
```sh
bash --version
```
output -> 3.2.53(1)-releaseThe actual installation is going to happen with HomeBrew, the OS X package manager, if you don’t have it, install it with the following command:
```sh
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
```Update homebrew packet database and install bash:
```sh
brew update && brew install bash
```Add the new shell to the list of allowed shells
```sh
sudo bash -c 'echo /usr/local/bin/bash >> /etc/shells'
```
Change to the new shell
```sh
chsh -s /usr/local/bin/bash
```# Now close terminal and open again
# installation
install shotgun GLOBALLY:
```sh
npm install -g xpress-shotgun
```
once installed run:
```sh
shotgun nameofapp dbname modelname(capital) controllername(plural) singularRESPONSE
```
# dependecies```ssh
"ejs": "^2.5.7",
"express": "^4.16.2",
"pg-promise": "^7.0.3"
```# PG promise
PG-PROMISE grants you accesss to DB query methods
* Automatic connections
* Automatic transactions
* Powerful query-formatting engine
* Support for ES6 generators and ES7 async/await
* Declarative approach to handling query results
* Global events reporting for central handling
* Extensive support for external SQL files
* Support for all promise libraries# examples
* Simple SELECT# ES5
```ssh
db.any('SELECT * FROM users WHERE active = $1', [true])
.then(function(data) {
// success;
})
.catch(function(error) {
// error;
});
```
# ES6
```ssh
try {
const users = yield db.any('SELECT * FROM users WHERE active = $1', [true]);
// success
}
catch(e) {
// error
}
```
# ES7
```ssh
try {
const users = await db.any('SELECT * FROM users WHERE active = $1', [true]);
// success
}
catch(e) {
// error
}
```****************************************************************************************
# ejsFeatures
* Control flow with <% %>
* Escaped output with <%= %> (escape function configurable)
* Unescaped raw output with <%- %>
* Newline-trim mode ('newline slurping') with -%> ending tag
* Whitespace-trim mode (slurp all whitespace) for control flow with <%_ _%>
* Custom delimiters (e.g., use ?> instead of <% %>)
* Includes
* Client-side support
* Static caching of intermediate JavaScript
* Static caching of templates
* Complies with the Express view system
# Examples
```ssh
<% if (user) { %>
<%= user.name %>
<% } %>
Try EJS online at: https://ionicabizau.github.io/ejs-playground/.
```
# Usage
```ssh
var template = ejs.compile(str, options);
template(data);
// => Rendered HTML string
ejs.render(str, data, options);
// => Rendered HTML string
ejs.renderFile(filename, data, options, function(err, str){
// str => Rendered HTML string
});
```