Skip to content
This repository has been archived by the owner on Dec 28, 2019. It is now read-only.

Commit

Permalink
Release 1.0.0
Browse files Browse the repository at this point in the history
- Added Favicon
- Updated Dependencies
- Rewrote express server
- Updated README
  • Loading branch information
V1ncNet committed Jan 7, 2018
1 parent 9d0babf commit bc3c72e
Show file tree
Hide file tree
Showing 7 changed files with 490 additions and 235 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Logs
logs
log/
*.log
npm-debug.log*
yarn-debug.log*
Expand Down
37 changes: 26 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# asciii GUI

... simplifies. asciii GUI is built with [Angular 5](https://angular.io).
... provides an alternative to the CLI of [asciii](https://github.com/ascii-dresden/asciii). The project helps our
members to evaluate and review our projects, clients, offers and clients.

asciii GUI is built with [Angular 5](https://angular.io) and was inspired by [InvoicePlane](https://github.com/InvoicePlane/InvoicePlane).

[![travis](https://travis-ci.org/ascii-dresden/ascii-hub.svg?branch=master)](https://travis-ci.org/ascii-dresden/ascii-hub/)
[![dependency Status](https://david-dm.org/ascii-dresden/ascii-hub.svg)](https://david-dm.org/ascii-dresden/ascii-hub)
Expand All @@ -9,47 +12,59 @@
[![GitHub forks](https://img.shields.io/github/forks/ascii-dresden/ascii-hub.svg?style=social&label=Fork)](https://github.com/ascii-dresden/ascii-hub/fork)
[![GitHub stars](https://img.shields.io/github/stars/ascii-dresden/ascii-hub.svg?style=social&label=Star)](https://github.com/ascii-dresden/ascii-hub)

> Build with :heart: in Dresden
> Built with :heart: in Dresden
## Preparation
## Setup

In order to build the project, you'll need NodeJS and NPM.

Install the dependencies.

```
npm install
```sh
$ npm install
```

## Development server
### Development

For a dev server run

```
ng serve
```sh
$ npm run start
```

To use the RESTful API from asciii you need to run a local instance of [rocket](https://github.com/SergioBenitez/Rocket). Checkout the asciii project and switch to [feature/server](https://github.com/ascii-dresden/asciii/tree/feature/server) branch. Run

```
cargo run --example server --features server
$ cargo run --example server --features server
```

to setup a local server instance. Read the asciii documentation for more information.

Since rocket runs on port 8000 by default, your browser will block Cross-Origin request. You'll have to allow
Cross-Origin requests to use the asciii REST API.

### i18n
#### i18n

To change your interface language to german run

```
npm run start:de
$ npm run start:de
```

Change currency and locale by editing `src/environments/environment.ts`.

### Production

1. Dowload the latest release from the [release](https://github.com/ascii-dresden/asciii-gui/releases/latest) section
2. Extract the package and copy all files to your webserver or destination machine
3. Start the asciii server as described [here](#dev)
4. Start the asciii GUI.

```sh
$ chmod +x ./bin/www
$ ./bin/www
```

## License

MIT - [ascii Dresden](https://github.com/ascii-dresden) - :heart:
49 changes: 40 additions & 9 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,61 @@
const express = require('express');
const path = require('path');
const fs = require('fs');
const favicon = require('serve-favicon');
const logger = require('morgan');
const morgan = require('morgan');
const bodyParser = require('body-parser');
const rfs = require('rotating-file-stream');

const app = express();
const logDirectory = path.join(__dirname, 'log');
const accessLogStream = rfs('access.log', {
interval: '1d',
path: logDirectory
});

fs.existsSync(logDirectory) || fs.mkdirSync(logDirectory);

app.use(logger('dev'));
app.use(morgan('dev', { skip: (req, res) => res.statusCode < 400 }));
app.use(morgan('common', { skip: (req, res) => app.get('env') !== 'production', stream: accessLogStream }));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, 'dist')));
app.use(notFound);
app.use(logErrors);
app.use(clientErrorHandler);
app.use(errorHandler);

app.use((req, res, next) => {
function notFound(req, res, next) {
const err = new Error('Not Found');
err.status = 404;
next(err);
});
}

app.use((err, req, res, next) => {
// set locals, only providing error in development
function logErrors(err, req, res, next) {
console.error(err.stack);
next(err);
}

function clientErrorHandler(err, req, res, next) {
if (req.xhr) {
res.status(500).send({ error: 'Something failed!' });
} else {
next(err);
}
}

function errorHandler(err, req, res, next) {
if (res.headersSent) {
return next(err);
}
res.locals.message = err.message;
res.locals.error = req.app.get('env') === 'development' ? err : {};

// render the error page
res.status(err.status || 500);
res.render('error');
});
res.json({
message: err.message,
error: err
});
}

module.exports = app;
20 changes: 14 additions & 6 deletions bin/www
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@
#!/usr/bin/env node

const app = require('../app');
const debug = require('debug')('mean-app:server');
const http = require('http');
const argv = require('minimist')(process.argv.slice(2));


const port = normalizePort(process.env.PORT || '3000');
const env = normalizeEnv(process.env.NODE_ENV || argv.prod || 'development');
app.set('env', env);

const port = normalizePort(process.env.PORT || argv.port || '3000');
app.set('port', port);

const server = http.createServer(app);
server.listen(port);
server.on('error', onError);
server.on('listening', onListening);

function normalizeEnv(val) {
if (val === true) {
return 'production';
} else {
return val;
}
}

function normalizePort(val) {
const port = parseInt(val, 10);

if (isNaN(port)) {
// named pipe
return val;
}

if (port >= 0) {
// port number
return port;
}

Expand All @@ -38,7 +47,6 @@ function onError(error) {
? 'Pipe ' + port
: 'Port ' + port;

// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(bind + ' requires elevated privileges');
Expand All @@ -58,5 +66,5 @@ function onListening() {
const bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
debug('Listening on ' + bind);
console.log(`Express server listening on port ${bind} in ${app.get('env')} mode.`);
}
Loading

0 comments on commit bc3c72e

Please sign in to comment.