Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

Commit

Permalink
Update WIP
Browse files Browse the repository at this point in the history
- run "npm update"
- clean package.json
- switch deprecated packages to non-deprecated ones
- mainly switch from "tsd" to "typings"
NOTE: node.d.ts and require.d.ts have been manually edited to prevent
Require and NodeRequire from clashing (see e.g.
DefinitelyTyped/DefinitelyTyped#7049 (comment))

- replace "throw err; return null;" with "return Promise.reject(err)",
as typescript and throwing does not work together (see e.g.
microsoft/TypeScript#7588)
- fix some other typing stuff
- fix 'use strict';s to be on top of the files

Please run "rm -r node_modules; npm install" after getting this commit.
  • Loading branch information
Blizzara committed Sep 1, 2016
1 parent b26b56d commit b8f67f7
Show file tree
Hide file tree
Showing 88 changed files with 2,143 additions and 1,985 deletions.
1 change: 0 additions & 1 deletion .jscsrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"esnext": true,
"fileExtensions": [".js", ".jsx"],
"requireCurlyBraces": [
"if",
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,10 @@ Running the enviroment

1. `npm install` for installing dependencies
2. Run `gulp`
3. Go to [http://localhost:3000/](http://localhost:3000/)
3. Go to [http://localhost:3000/](http://localhost:3000/)


Adding typings
-------------

Use `typings` (e.g. `npm install --global typings`)
3 changes: 2 additions & 1 deletion app.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

import {Response} from 'express';
import {Request} from 'express';
'use strict';

import util = require('util');
var express = require('express');
Expand Down
7 changes: 3 additions & 4 deletions backend/src/order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export function checkPaytrailStatus(order_id: number): Promise<string> {
var verification = [config.paytrail.password, config.paytrail.user, PAYTRAIL_PREFIX + order_id].join('&');
var authcode = md5(verification).toUpperCase();

return new Promise((resolve, reject) => {
return new Promise<string>((resolve, reject) => {
var jar = request.jar();
request.post({
url: 'https://payment.paytrail.com/check-payment',
Expand All @@ -93,7 +93,7 @@ export function checkPaytrailStatus(order_id: number): Promise<string> {
(err) ? reject(err) : resolve(body);
});
}).then((body: string) => {
return new Promise((resolve, reject) => {
return new Promise<string>((resolve, reject) => {
jsdom.env({
html: body,
src: [fs.readFileSync('./node_modules/jquery/dist/jquery.js', 'utf-8')],
Expand Down Expand Up @@ -326,8 +326,7 @@ export function get(order_id: number): Promise<IOrder> {
})
.catch((err) => {
log.error('Failed to get order', {order_id: order_id, error: err});
throw err;
return null;
return Promise.reject(err);
});
}

Expand Down
15 changes: 5 additions & 10 deletions backend/src/production.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ export function getLatestActive(): Promise<IProduction> {
})
.catch((err) => {
log.error('Getting the latest active production failed', {error: err});
throw err;
return null;
return Promise.reject(err);
});
}

Expand All @@ -50,17 +49,15 @@ export function getAll(production_id?: number): Promise<IProduction[]> {
})
.catch((err) => {
log.error('Getting the latest active production failed', {error: err});
throw err;
return null;
return Promise.reject(err);
});
}

export function get(production_id): Promise<IProduction> {
return getAll(production_id).then((productions: IProduction[]) => productions[0])
.catch((err) => {
log.error('Getting a production failed', {error: err});
throw err;
return null;
return Promise.reject(err);
});
}

Expand All @@ -75,8 +72,7 @@ export function create(production: IProduction): Promise<IProduction> {
})
.catch((err) => {
log.error('ADMIN: Creating a production failed', {error: err});
throw err;
return null;
return Promise.reject(err);
});
}

Expand All @@ -90,7 +86,6 @@ export function update(production_id: number, production: IProduction): Promise<
})
.catch((err) => {
log.error('ADMIN: Updating a production failed', {error: err});
throw err;
return null;
return Promise.reject(err);
});
}
12 changes: 4 additions & 8 deletions backend/src/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ export function get(show_id: number, user?: string): Promise<IShow> {
return getAll(user).then((shows: IShow[]) => shows.filter((show2: IShow) => show2.id === show_id)[0])
.catch((err) => {
log.error('Getting a show failed', {error: err});
throw err;
return null;
return Promise.reject(err);
});
}

Expand All @@ -110,8 +109,7 @@ export function getReservedSeats(show_id: number): Promise<IReservedSeats> {
})
.catch((err) => {
log.error('Getting reserved seats failed', {error: err, show_id: show_id});
throw err;
return null;
return Promise.reject(err);
});
}

Expand All @@ -137,8 +135,7 @@ export function create(show: IShow): Promise<IShow> {
})
.catch((err) => {
log.error('ADMIN: Creating a show failed', {error: err});
throw err;
return null;
return Promise.reject(err);
});
}

Expand Down Expand Up @@ -168,7 +165,6 @@ export function update(show_id: number, show: IShow): Promise<IShow> {
})
.catch((err) => {
log.error('ADMIN: Updating a show failed', {error: err});
throw err;
return null;
return Promise.reject(err);
});
}
2 changes: 1 addition & 1 deletion backend/src/ticket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface ITicket {

export function generatePdf(tickets: ITicket[]) {
var margin = 50;
var options = {size: 'A4', margins: {left: margin, right: margin, top: 72, bottom: 0}}; // A4: [595.28, 841.89]
var options = {size: [595.28, 841.89], margins: {left: margin, right: margin, top: 72, bottom: 0}}; // A4: [595.28, 841.89]
var width = 595.28;
var height = 841.89;
var doc = new PDFDocument(options);
Expand Down
12 changes: 5 additions & 7 deletions backend/src/venue.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Dictionary = _.Dictionary;
'use strict';

import Dictionary = _.Dictionary;

import db = require('./db');
import log = require('./log');
import _ = require('underscore');
Expand Down Expand Up @@ -85,17 +86,15 @@ export function getAll(venue_id?: number): Promise<IVenue[]> {
})
.catch((err) => {
log.error('Getting all venues failed', {error: err});
throw err;
return null;
return Promise.reject(err);
});
}

export function get(venue_id): Promise<IVenue> {
return getAll(venue_id).then((venues: IVenue[]) => venues[0])
.catch((err) => {
log.error('Getting a venue failed', {error: err});
throw err;
return null;
return Promise.reject(err);
});
}

Expand Down Expand Up @@ -123,7 +122,6 @@ export function update(venue_id: number, venue: IVenue): Promise<IVenue> {
})
.catch((err) => {
log.error('ADMIN: Updating a venue failed', {error: err});
throw err;
return null;
return Promise.reject(err);
});
}
2 changes: 1 addition & 1 deletion frontend/src/js-admin/components/Show.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface IShowProps {
export interface IShowState {
shows?: IShow[];
show?: IShow;
show_id? : number;
show_id?: number;
venues?: IVenue[];
productions?: IProduction[];
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/js/components/FinalConfirmation.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import ReactElement = __React.ReactElement;
'use strict';

import ReactElement = __React.ReactElement;

import React = require('react');
import Bootstrap = require('react-bootstrap');
import {IOrder} from '../../../../backend/src/order';
Expand Down Expand Up @@ -35,7 +36,6 @@ export default class FinalConfirmation extends React.Component<IFinalConfirmatio
}
var active = !this.props.paymentBegun;
return (

<div className='shopping-stage final-confirmation'>
<h2>Vahvistus <small>5/5</small></h2>
<table className='table table-bordered'>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/js/components/Seat.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import EventHandler = __React.EventHandler;
;
'use strict';

import EventHandler = __React.EventHandler;

import React = require('react');
import Props = __React.Props;
import {ISeat} from '../../../../backend/src/venue';
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/js/components/Store.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {IOrder} from '../../../../backend/src/order';
'use strict';

import React = require('react');
Expand All @@ -17,6 +16,7 @@ import ShoppingCart from './ShoppingCart.tsx';
import Contacts from './Contacts.tsx';
import FinalConfirmation from './FinalConfirmation.tsx';

import {IOrder} from '../../../../backend/src/order';
import {IProduction} from '../../../../backend/src/production';
import {IShow, IReservedSeats} from '../../../../backend/src/show';
import {IDiscountGroup} from '../../../../backend/src/discountGroup';
Expand Down
18 changes: 9 additions & 9 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@ var less = require('gulp-less');
var del = require('del');
var runSequence = require('run-sequence');
var browserify = require('browserify');
var reactify = require('reactify'); // for browserify
var babelify = require('babelify'); // for browserify
var tsify = require('tsify');
var ts = require('gulp-typescript');
var tslint = require('gulp-tslint');
var stylish = require('gulp-tslint-stylish');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var uglify = require('gulp-uglify');
var react = require('gulp-react'); // for jshint
var concat = require('gulp-concat');
var cssmin = require('gulp-minify-css');
var cssmin = require('gulp-clean-css');
var plumber = require('gulp-plumber');
var notify = require('gulp-notify');
var lr = require('tiny-lr')();
Expand Down Expand Up @@ -111,14 +110,15 @@ function js(startPath, targetFile) {
return function() {
return browserify(startPath)
.add(startPath)
.add('typings/tsd.d.ts')
.transform(reactify)
.add('typings/index.d.ts')
.transform(babelify)
.plugin(tsify)
.bundle()
.on('error', function(err) {
notify.onError({
message: '<%= error.message %>'
}).apply(this, arguments);

this.emit('end');
})
.pipe(source(targetFile))
Expand All @@ -130,8 +130,8 @@ function jsMin(startPath, targetFile) {
return function() {
return browserify()
.add(startPath)
.add('typings/tsd.d.ts')
.transform(reactify)
.add('typings/index.d.ts')
.transform(babelify)
.plugin(tsify)
.bundle()
.pipe(source(targetFile))
Expand All @@ -152,7 +152,7 @@ gulp.task('js:admin:min', jsMin('./frontend/src/js-admin/AdminApp.tsx', 'adminAp
gulp.task('js:min', ['js:store:min', 'js:admin:min']);

gulp.task('backend', function() {
return gulp.src(['backend/src/**/*.ts', 'typings/tsd.d.ts'])
return gulp.src(['backend/src/**/*.ts', 'typings/index.d.ts'])
.pipe(ts({
module: 'commonjs'
}))
Expand All @@ -161,7 +161,7 @@ gulp.task('backend', function() {
});

gulp.task('app', function() {
return gulp.src(['app.ts', 'typings/tsd.d.ts'])
return gulp.src(['app.ts', 'typings/index.d.ts'])
.pipe(ts({
module: 'commonjs'
}))
Expand Down
46 changes: 20 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,66 +6,60 @@
"start": "node ./bin/www"
},
"dependencies": {
"atob": "^2.0.0",
"backbone": "^1.2.1",
"atob": "^2.0.3",
"backbone": "^1.3.3",
"body-parser": "1.14.0",
"compression": "1.6.0",
"connect-livereload": "^0.5.3",
"debug": "~2.2.0",
"es6-promise": "^3.0.2",
"es6-promise": "^3.2.1",
"express": "~4.13.1",
"http-auth": "2.2.8",
"jquery": "^2.1.4",
"jquery": "^2.2.4",
"jsdom": "^7.2.2",
"marked": "^0.3.5",
"mailgun-js": "^0.7.7",
"mailgun-js": "^0.7.12",
"marked": "^0.3.6",
"md5": "2.0.0",
"method-override": "^2.3.5",
"moment": "^2.11.0",
"moment-timezone": "^0.5.0",
"method-override": "^2.3.6",
"moment": "^2.14.1",
"moment-timezone": "^0.5.5",
"morgan": "^1.6.1",
"mysql": "2.8.0",
"node-uuid": "^1.4.7",
"nodemailer": "1.4.0",
"pdfkit": "^0.7.1",
"qr-image": "^3.1.0",
"request": "2.64.0",
"run-sequence": "^1.1.2",
"stream-to-array": "^2.2.0",
"tsify": "^0.13.1",
"underscore": "^1.8.3",
"winston": "1.1.0"
},
"devDependencies": {
"babel-preset-react": "^6.11.1",
"babelify": "^7.3.0",
"browserify": "^11.0.0",
"del": "^1.2.0",
"gulp": "^3.9.0",
"gulp-clean-css": "^2.0.12",
"gulp-concat": "^2.6.0",
"gulp-inject": "^1.5.0",
"gulp-jscs": "^3.0.1",
"gulp-jscs-stylish": "^1.2.1",
"gulp-jshint": "^1.11.2",
"gulp-less": "^3.0.3",
"gulp-less": "^3.1.0",
"gulp-livereload": "^3.8.0",
"gulp-minify-css": "^1.2.0",
"gulp-nightwatch": "^0.2.7",
"gulp-notify": "^2.2.0",
"gulp-plumber": "^1.0.1",
"gulp-react": "^3.0.1",
"gulp-tslint": "^4.2.2",
"gulp-tslint": "^4.3.5",
"gulp-tslint-stylish": "^1.1.1",
"gulp-typescript": "^2.10.0",
"gulp-uglify": "^1.2.0",
"jshint-stylish": "^2.0.1",
"gulp-typescript": "^2.13.6",
"gulp-uglify": "^1.5.4",
"nightwatch": "^0.8.9",
"react": "^0.14.0",
"react": "^0.14.8",
"react-bootstrap": "^0.27.2",
"react-dom": "^0.14.0",
"reactify": "^1.1.1",
"run-sequence": "^1.2.2",
"tiny-lr": "^0.1.6",
"tsd": "^0.6.5",
"tslint": "^3.2.1",
"typescript": "^1.7.5",
"tsify": "^0.13.1",
"tslint": "^3.15.1",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0"
}
Expand Down
Loading

0 comments on commit b8f67f7

Please sign in to comment.