diff --git a/client/config/webpack.common.js b/client/config/webpack.common.js index 266e630f6..459985880 100644 --- a/client/config/webpack.common.js +++ b/client/config/webpack.common.js @@ -168,6 +168,13 @@ module.exports = function (options) { helpers.root('src/index.html'), helpers.root('src/standalone/videos/embed.html') ] + }, + + /* File loader for supporting images, for example, in CSS files. + */ + { + test: /\.(jpg|png|gif)$/, + use: 'file-loader' } ] @@ -271,7 +278,7 @@ module.exports = function (options) { * See: https://github.com/numical/script-ext-html-webpack-plugin */ new ScriptExtHtmlWebpackPlugin({ - sync: [ /polyfill|vendor/, 'webtorrent.min.js' ], + sync: [ /polyfill|vendor/ ], defaultAttribute: 'async', preload: [/polyfill|vendor|main/], prefetch: [/chunk/] diff --git a/client/config/webpack.dev.js b/client/config/webpack.dev.js index 03d6d2fba..d6ebed730 100644 --- a/client/config/webpack.dev.js +++ b/client/config/webpack.dev.js @@ -22,7 +22,8 @@ const METADATA = webpackMerge(commonConfig({env: ENV}).metadata, { host: HOST, port: PORT, ENV: ENV, - HMR: HMR + HMR: HMR, + API_URL: 'http://localhost:9000' }) const DllBundlesPlugin = require('webpack-dll-bundles-plugin').DllBundlesPlugin @@ -79,9 +80,7 @@ module.exports = function (env) { chunkFilename: '[id].chunk.js', library: 'ac_[name]', - libraryTarget: 'var', - - publicPath: '/client/' + libraryTarget: 'var' }, externals: { @@ -125,6 +124,7 @@ module.exports = function (env) { new DefinePlugin({ 'ENV': JSON.stringify(METADATA.ENV), 'HMR': METADATA.HMR, + 'API_URL': JSON.stringify(METADATA.API_URL), 'process.env': { 'ENV': JSON.stringify(METADATA.ENV), 'NODE_ENV': JSON.stringify(METADATA.ENV), @@ -234,8 +234,7 @@ module.exports = function (env) { historyApiFallback: true, watchOptions: { ignored: /node_modules/ - }, - outputPath: helpers.root('dist') + } }, /* diff --git a/client/config/webpack.prod.js b/client/config/webpack.prod.js index 9bb7306af..3f063c7c6 100644 --- a/client/config/webpack.prod.js +++ b/client/config/webpack.prod.js @@ -26,7 +26,8 @@ const METADATA = webpackMerge(commonConfig({env: ENV}).metadata, { host: HOST, port: PORT, ENV: ENV, - HMR: false + HMR: false, + API_URL: '' }) module.exports = function (env) { @@ -125,6 +126,7 @@ module.exports = function (env) { new DefinePlugin({ 'ENV': JSON.stringify(METADATA.ENV), 'HMR': METADATA.HMR, + 'API_URL': JSON.stringify(METADATA.API_URL), 'process.env': { 'ENV': JSON.stringify(METADATA.ENV), 'NODE_ENV': JSON.stringify(METADATA.ENV), diff --git a/client/package.json b/client/package.json index dbf9ef06d..aee548c3f 100644 --- a/client/package.json +++ b/client/package.json @@ -14,7 +14,8 @@ }, "scripts": { "test": "standard && tslint -c ./tslint.json src/**/*.ts", - "webpack": "webpack" + "webpack": "webpack", + "webpack-dev-server": "webpack-dev-server" }, "license": "GPLv3", "dependencies": { @@ -57,8 +58,8 @@ "json-loader": "^0.5.4", "ng-router-loader": "^2.0.0", "ng2-file-upload": "^1.1.4-2", - "ng2-smart-table": "1.0.3", - "ng2-tag-input": "1.0.5", + "ng2-smart-table": "1.2.1", + "ng2-tag-input": "1.3.3", "ngc-webpack": "2.0.0", "ngx-bootstrap": "1.6.6", "node-sass": "^4.1.1", @@ -90,8 +91,10 @@ "devDependencies": { "add-asset-html-webpack-plugin": "^2.0.1", "codelyzer": "^3.0.0-beta.4", + "ng2-completer": "1.2.2", "standard": "^10.0.0", "webpack-bundle-analyzer": "^2.8.2", + "webpack-dev-server": "^2.4.5", "webpack-dll-bundles-plugin": "^1.0.0-beta.5" } } diff --git a/client/src/app/+admin/friends/shared/friend.service.ts b/client/src/app/+admin/friends/shared/friend.service.ts index 6cb84f5cd..6e51c954f 100644 --- a/client/src/app/+admin/friends/shared/friend.service.ts +++ b/client/src/app/+admin/friends/shared/friend.service.ts @@ -10,7 +10,7 @@ import { AuthHttp, RestExtractor, RestDataSource, ResultList } from '../../../sh @Injectable() export class FriendService { - private static BASE_FRIEND_URL: string = '/api/v1/pods/'; + private static BASE_FRIEND_URL = API_URL + '/api/v1/pods/'; constructor ( private authHttp: AuthHttp, diff --git a/client/src/app/+admin/requests/shared/request.service.ts b/client/src/app/+admin/requests/shared/request.service.ts index 915d192a6..0872ba0b8 100644 --- a/client/src/app/+admin/requests/shared/request.service.ts +++ b/client/src/app/+admin/requests/shared/request.service.ts @@ -8,7 +8,7 @@ import { AuthHttp, RestExtractor } from '../../../shared'; @Injectable() export class RequestService { - private static BASE_REQUEST_URL: string = '/api/v1/requests/'; + private static BASE_REQUEST_URL = API_URL + '/api/v1/requests/'; constructor ( private authHttp: AuthHttp, diff --git a/client/src/app/+admin/users/shared/user.service.ts b/client/src/app/+admin/users/shared/user.service.ts index da540bf9f..9c7176d39 100644 --- a/client/src/app/+admin/users/shared/user.service.ts +++ b/client/src/app/+admin/users/shared/user.service.ts @@ -6,7 +6,7 @@ import { AuthHttp, RestExtractor, RestDataSource, User } from '../../../shared'; @Injectable() export class UserService { - private static BASE_USERS_URL = '/api/v1/users/'; + private static BASE_USERS_URL = API_URL + '/api/v1/users/'; constructor( private authHttp: AuthHttp, diff --git a/client/src/app/app.component.scss b/client/src/app/app.component.scss index 68fadbe7c..a98e57cc3 100644 --- a/client/src/app/app.component.scss +++ b/client/src/app/app.component.scss @@ -51,7 +51,7 @@ a { color: inherit !important; display: block; - background: url(/client/assets/logo.png) no-repeat; + background: url(/assets/logo.png) no-repeat; background-size: contain; background-position: center; height: 100%; diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts index caf765b42..4c75df1ca 100644 --- a/client/src/app/core/auth/auth.service.ts +++ b/client/src/app/core/auth/auth.service.ts @@ -16,9 +16,9 @@ import { RestExtractor } from '../../shared/rest'; @Injectable() export class AuthService { - private static BASE_CLIENT_URL = '/api/v1/clients/local'; - private static BASE_TOKEN_URL = '/api/v1/users/token'; - private static BASE_USER_INFORMATIONS_URL = '/api/v1/users/me'; + private static BASE_CLIENT_URL = API_URL + '/api/v1/clients/local'; + private static BASE_TOKEN_URL = API_URL + '/api/v1/users/token'; + private static BASE_USER_INFORMATIONS_URL = API_URL + '/api/v1/users/me'; loginChangedSource: Observable; diff --git a/client/src/app/core/config/config.service.ts b/client/src/app/core/config/config.service.ts index 295e68c36..407dca083 100644 --- a/client/src/app/core/config/config.service.ts +++ b/client/src/app/core/config/config.service.ts @@ -5,7 +5,7 @@ import { RestExtractor } from '../../shared/rest'; @Injectable() export class ConfigService { - private static BASE_CONFIG_URL = '/api/v1/config/'; + private static BASE_CONFIG_URL = API_URL + '/api/v1/config/'; private config: { signup: { diff --git a/client/src/app/shared/users/user.service.ts b/client/src/app/shared/users/user.service.ts index 0727b76fd..f1265be0a 100644 --- a/client/src/app/shared/users/user.service.ts +++ b/client/src/app/shared/users/user.service.ts @@ -9,7 +9,7 @@ import { RestExtractor } from '../rest'; @Injectable() export class UserService { - static BASE_USERS_URL = '/api/v1/users/'; + static BASE_USERS_URL = API_URL + '/api/v1/users/'; constructor( private http: Http, diff --git a/client/src/app/shared/video-abuse/video-abuse.service.ts b/client/src/app/shared/video-abuse/video-abuse.service.ts index f23c36f05..da7b2ef8a 100644 --- a/client/src/app/shared/video-abuse/video-abuse.service.ts +++ b/client/src/app/shared/video-abuse/video-abuse.service.ts @@ -11,7 +11,7 @@ import { VideoAbuse } from './video-abuse.model'; @Injectable() export class VideoAbuseService { - private static BASE_VIDEO_ABUSE_URL = '/api/v1/videos/'; + private static BASE_VIDEO_ABUSE_URL = API_URL + '/api/v1/videos/'; constructor( private authHttp: AuthHttp, diff --git a/client/src/app/videos/shared/video.model.ts b/client/src/app/videos/shared/video.model.ts index 0cf4039df..e897eb175 100644 --- a/client/src/app/videos/shared/video.model.ts +++ b/client/src/app/videos/shared/video.model.ts @@ -21,6 +21,7 @@ export class Video implements VideoServerModel { podHost: string; tags: string[]; thumbnailPath: string; + thumbnailUrl: string; views: number; likes: number; dislikes: number; @@ -80,6 +81,7 @@ export class Video implements VideoServerModel { this.podHost = hash.podHost; this.tags = hash.tags; this.thumbnailPath = hash.thumbnailPath; + this.thumbnailUrl = API_URL + hash.thumbnailPath; this.views = hash.views; this.likes = hash.likes; this.dislikes = hash.dislikes; diff --git a/client/src/app/videos/shared/video.service.ts b/client/src/app/videos/shared/video.service.ts index ef683dea6..a53ea1064 100644 --- a/client/src/app/videos/shared/video.service.ts +++ b/client/src/app/videos/shared/video.service.ts @@ -20,7 +20,7 @@ import { Video } from './video.model'; @Injectable() export class VideoService { - private static BASE_VIDEO_URL = '/api/v1/videos/'; + private static BASE_VIDEO_URL = API_URL + '/api/v1/videos/'; videoCategories: Array<{ id: number, label: string }> = []; videoLicences: Array<{ id: number, label: string }> = []; diff --git a/client/src/app/videos/video-edit/video-add.component.ts b/client/src/app/videos/video-edit/video-add.component.ts index 21343880d..e5eb9a9f4 100644 --- a/client/src/app/videos/video-edit/video-add.component.ts +++ b/client/src/app/videos/video-edit/video-add.component.ts @@ -94,7 +94,7 @@ export class VideoAddComponent extends FormReactive implements OnInit { this.uploader = new FileUploader({ authToken: this.authService.getRequestHeaderValue(), queueLimit: 1, - url: '/api/v1/videos', + url: API_URL + '/api/v1/videos', removeAfterUpload: true }); diff --git a/client/src/app/videos/video-list/video-miniature.component.html b/client/src/app/videos/video-list/video-miniature.component.html index b1b881fea..db6c4d6fb 100644 --- a/client/src/app/videos/video-list/video-miniature.component.html +++ b/client/src/app/videos/video-list/video-miniature.component.html @@ -3,7 +3,7 @@ [routerLink]="['/videos/watch', video.id]" [attr.title]="video.description" class="video-miniature-thumbnail" > - video thumbnail + video thumbnail
NSFW
diff --git a/client/src/custom-typings.d.ts b/client/src/custom-typings.d.ts index 621a416b4..67e069cc6 100644 --- a/client/src/custom-typings.d.ts +++ b/client/src/custom-typings.d.ts @@ -58,6 +58,7 @@ declare module 'modern-lru' { // Extra variables that live on Global that will be replaced by webpack DefinePlugin declare var ENV: string; +declare var API_URL: string; declare var HMR: boolean; declare var System: SystemJS; @@ -67,6 +68,7 @@ interface SystemJS { interface GlobalEnvironment { ENV: string; + API_URL: string; HMR: boolean; SystemJS: SystemJS; System: SystemJS; diff --git a/client/src/index.html b/client/src/index.html index e18b83dc8..ea88bb15b 100644 --- a/client/src/index.html +++ b/client/src/index.html @@ -12,7 +12,7 @@ - + diff --git a/client/yarn.lock b/client/yarn.lock index 383f4541f..68e4116ac 100644 --- a/client/yarn.lock +++ b/client/yarn.lock @@ -212,6 +212,10 @@ ansi-escapes@^1.1.0: version "1.4.0" resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-1.4.0.tgz#d3a8a83b319aa67793662b13e761c7911422306e" +ansi-html@0.0.7: + version "0.0.7" + resolved "https://registry.yarnpkg.com/ansi-html/-/ansi-html-0.0.7.tgz#813584021962a9e9e6fd039f940d12f56ca7859e" + ansi-regex@^2.0.0: version "2.1.1" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" @@ -347,6 +351,10 @@ async@^0.9.0: version "0.9.2" resolved "https://registry.yarnpkg.com/async/-/async-0.9.2.tgz#aea74d5e61c1f899613bf64bda66d4c78f2fd17d" +async@^1.5.2: + version "1.5.2" + resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" + async@^2.1.2, async@^2.1.4, async@^2.1.5: version "2.4.1" resolved "https://registry.yarnpkg.com/async/-/async-2.4.1.tgz#62a56b279c98a11d0987096a01cc3eeb8eb7bbd7" @@ -415,6 +423,10 @@ base64-js@^1.0.2: version "1.2.0" resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.2.0.tgz#a39992d723584811982be5e290bb6a53d86700f1" +batch@0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/batch/-/batch-0.6.1.tgz#dc34314f4e679318093fc760272525f94bf25c16" + bcrypt-pbkdf@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz#63bc5dcb61331b92bc05fd528953c33462a06f8d" @@ -695,6 +707,10 @@ builtin-status-codes@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8" +bytes@2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/bytes/-/bytes-2.3.0.tgz#d5b680a165b6201739acb611542aabc2d8ceb070" + caller-path@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/caller-path/-/caller-path-0.1.0.tgz#94085ef63581ecd3daa92444a8fe94e82577751f" @@ -776,7 +792,7 @@ chalk@^1.0.0, chalk@^1.1.0, chalk@^1.1.1, chalk@^1.1.3: strip-ansi "^3.0.0" supports-color "^2.0.0" -chokidar@^1.4.3: +chokidar@^1.4.3, chokidar@^1.6.0: version "1.7.0" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468" dependencies: @@ -965,6 +981,23 @@ compact2string@^1.2.0: dependencies: ipaddr.js ">= 0.1.5" +compressible@~2.0.8: + version "2.0.10" + resolved "https://registry.yarnpkg.com/compressible/-/compressible-2.0.10.tgz#feda1c7f7617912732b29bf8cf26252a20b9eecd" + dependencies: + mime-db ">= 1.27.0 < 2" + +compression@^1.5.2: + version "1.6.2" + resolved "https://registry.yarnpkg.com/compression/-/compression-1.6.2.tgz#cceb121ecc9d09c52d7ad0c3350ea93ddd402bc3" + dependencies: + accepts "~1.3.3" + bytes "2.3.0" + compressible "~2.0.8" + debug "~2.2.0" + on-headers "~1.0.1" + vary "~1.1.0" + concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" @@ -977,6 +1010,10 @@ concat-stream@^1.5.1, concat-stream@^1.5.2: readable-stream "^2.2.2" typedarray "^0.0.6" +connect-history-api-fallback@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/connect-history-api-fallback/-/connect-history-api-fallback-1.3.0.tgz#e51d17f8f0ef0db90a64fdb47de3051556e9f169" + console-browserify@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/console-browserify/-/console-browserify-1.1.0.tgz#f0241c45730a9fc6323b206dbf38edc741d0bb10" @@ -1253,7 +1290,7 @@ debug-log@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/debug-log/-/debug-log-1.0.1.tgz#2307632d4c04382b8df8a32f70b895046d52745f" -debug@2.2.0: +debug@2.2.0, debug@~2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da" dependencies: @@ -1265,7 +1302,7 @@ debug@2.6.7: dependencies: ms "2.0.0" -debug@^2.0.0, debug@^2.1.0, debug@^2.1.1, debug@^2.1.3, debug@^2.2.0, debug@^2.5.2, debug@^2.6.3: +debug@2.6.8, debug@^2.0.0, debug@^2.1.0, debug@^2.1.1, debug@^2.1.3, debug@^2.2.0, debug@^2.5.2, debug@^2.6.3, debug@^2.6.8: version "2.6.8" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc" dependencies: @@ -1340,6 +1377,10 @@ destroy@~1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.0.4.tgz#978857442c44749e4206613e37946205826abd80" +detect-node@^2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/detect-node/-/detect-node-2.0.3.tgz#a2033c09cc8e158d37748fbde7507832bd6ce127" + diff@^3.1.0, diff@^3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/diff/-/diff-3.2.0.tgz#c9ce393a4b7cbd0b058a725c93df299027868ff9" @@ -1750,10 +1791,20 @@ event-emitter@~0.3.5: d "1" es5-ext "~0.10.14" +eventemitter3@1.x.x: + version "1.2.0" + resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-1.2.0.tgz#1c86991d816ad1e504750e73874224ecf3bec508" + events@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/events/-/events-1.1.1.tgz#9ebdb7635ad099c70dcc4c2a1f5004288e8bd924" +eventsource@0.1.6: + version "0.1.6" + resolved "https://registry.yarnpkg.com/eventsource/-/eventsource-0.1.6.tgz#0acede849ed7dd1ccc32c811bb11b944d4f29232" + dependencies: + original ">=0.0.5" + evp_bytestokey@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/evp_bytestokey/-/evp_bytestokey-1.0.0.tgz#497b66ad9fef65cd7c08a6180824ba1476b66e53" @@ -1787,7 +1838,7 @@ exports-loader@^0.6.3: loader-utils "^1.0.2" source-map "0.5.x" -express@^4.15.2: +express@^4.13.3, express@^4.15.2: version "4.15.3" resolved "https://registry.yarnpkg.com/express/-/express-4.15.3.tgz#bab65d0f03aa80c358408972fc700f916944b662" dependencies: @@ -1842,6 +1893,18 @@ fastparse@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/fastparse/-/fastparse-1.1.1.tgz#d1e2643b38a94d7583b479060e6c4affc94071f8" +faye-websocket@^0.10.0: + version "0.10.0" + resolved "https://registry.yarnpkg.com/faye-websocket/-/faye-websocket-0.10.0.tgz#4e492f8d04dfb6f89003507f6edbf2d501e7c6f4" + dependencies: + websocket-driver ">=0.5.1" + +faye-websocket@~0.11.0: + version "0.11.1" + resolved "https://registry.yarnpkg.com/faye-websocket/-/faye-websocket-0.11.1.tgz#f0efe18c4f56e4f40afc7e06c719fd5ee6188f38" + dependencies: + websocket-driver ">=0.5.1" + figures@^1.3.5: version "1.7.0" resolved "https://registry.yarnpkg.com/figures/-/figures-1.7.0.tgz#cbe1e3affcf1cd44b80cadfed28dc793a9701d2e" @@ -2172,6 +2235,10 @@ gzip-size@^3.0.0: dependencies: duplexer "^0.1.1" +handle-thing@^1.2.5: + version "1.2.5" + resolved "https://registry.yarnpkg.com/handle-thing/-/handle-thing-1.2.5.tgz#fd7aad726bf1a5fd16dfc29b2f7a6601d27139c4" + har-schema@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-1.0.5.tgz#d263135f43307c02c602afc8fe95970c0151369e" @@ -2244,10 +2311,23 @@ hosted-git-info@^2.1.4: version "2.4.2" resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.4.2.tgz#0076b9f46a270506ddbaaea56496897460612a67" +hpack.js@^2.1.6: + version "2.1.6" + resolved "https://registry.yarnpkg.com/hpack.js/-/hpack.js-2.1.6.tgz#87774c0949e513f42e84575b3c45681fade2a0b2" + dependencies: + inherits "^2.0.1" + obuf "^1.0.0" + readable-stream "^2.0.1" + wbuf "^1.1.0" + html-comment-regex@^1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/html-comment-regex/-/html-comment-regex-1.1.1.tgz#668b93776eaae55ebde8f3ad464b307a4963625e" +html-entities@^1.2.0: + version "1.2.1" + resolved "https://registry.yarnpkg.com/html-entities/-/html-entities-1.2.1.tgz#0df29351f0721163515dfb9e5543e5f6eed5162f" + html-minifier@^3.2.3: version "3.5.2" resolved "https://registry.yarnpkg.com/html-minifier/-/html-minifier-3.5.2.tgz#d73bc3ff448942408818ce609bf3fb0ea7ef4eb7" @@ -2281,6 +2361,10 @@ htmlparser2@~3.3.0: domutils "1.1" readable-stream "1.0" +http-deceiver@^1.2.7: + version "1.2.7" + resolved "https://registry.yarnpkg.com/http-deceiver/-/http-deceiver-1.2.7.tgz#fa7168944ab9a519d337cb0bec7284dc3e723d87" + http-errors@~1.6.1: version "1.6.1" resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.6.1.tgz#5f8b8ed98aca545656bf572997387f904a722257" @@ -2290,6 +2374,22 @@ http-errors@~1.6.1: setprototypeof "1.0.3" statuses ">= 1.3.1 < 2" +http-proxy-middleware@~0.17.4: + version "0.17.4" + resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-0.17.4.tgz#642e8848851d66f09d4f124912846dbaeb41b833" + dependencies: + http-proxy "^1.16.2" + is-glob "^3.1.0" + lodash "^4.17.2" + micromatch "^2.3.11" + +http-proxy@^1.16.2: + version "1.16.2" + resolved "https://registry.yarnpkg.com/http-proxy/-/http-proxy-1.16.2.tgz#06dff292952bf64dbe8471fa9df73066d4f37742" + dependencies: + eventemitter3 "1.x.x" + requires-port "1.x.x" + http-signature@~1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.1.1.tgz#df72e267066cd0ac67fb76adf8e134a8fbcf91bf" @@ -2674,6 +2774,10 @@ json-stringify-safe@~5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" +json3@^3.3.2: + version "3.3.2" + resolved "https://registry.yarnpkg.com/json3/-/json3-3.3.2.tgz#3c0434743df93e2f5c42aee7b19bcb483575f4e1" + json5@^0.5.0, json5@^0.5.1: version "0.5.1" resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" @@ -3007,7 +3111,7 @@ lodash.uniq@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" -lodash@^4, lodash@^4.0.0, lodash@^4.14.0, lodash@^4.17.3, lodash@^4.17.4, lodash@^4.3.0, lodash@~4.17.4: +lodash@^4, lodash@^4.0.0, lodash@^4.14.0, lodash@^4.17.2, lodash@^4.17.3, lodash@^4.17.4, lodash@^4.3.0, lodash@~4.17.4: version "4.17.4" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" @@ -3130,7 +3234,7 @@ methods@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" -micromatch@^2.1.5: +micromatch@^2.1.5, micromatch@^2.3.11: version "2.3.11" resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-2.3.11.tgz#86677c97d1720b363431d04d0d15293bd38c1565" dependencies: @@ -3155,7 +3259,7 @@ miller-rabin@^4.0.0: bn.js "^4.0.0" brorand "^1.0.1" -mime-db@~1.27.0: +"mime-db@>= 1.27.0 < 2", mime-db@~1.27.0: version "1.27.0" resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.27.0.tgz#820f572296bbd20ec25ed55e5b5de869e5436eb1" @@ -3208,7 +3312,7 @@ mixin-object@^2.0.1: for-in "^0.1.3" is-extendable "^0.1.1" -"mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0, mkdirp@~0.5.1: +mkdirp@0.5.x, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0, mkdirp@~0.5.1: version "0.5.1" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" dependencies: @@ -3285,9 +3389,9 @@ ng-router-loader@^2.0.0: loader-utils "^0.2.16" recast "^0.11.20" -ng2-completer@^1.2.2: - version "1.5.0" - resolved "https://registry.yarnpkg.com/ng2-completer/-/ng2-completer-1.5.0.tgz#335d29bcfa433981d948e55a041ac912f10f47ec" +ng2-completer@1.2.2, ng2-completer@^1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/ng2-completer/-/ng2-completer-1.2.2.tgz#69515e4d65973abce1276aea301cf0f36e5846a4" ng2-file-upload@^1.1.4-2: version "1.2.1" @@ -3297,16 +3401,16 @@ ng2-material-dropdown@0.7.7: version "0.7.7" resolved "https://registry.yarnpkg.com/ng2-material-dropdown/-/ng2-material-dropdown-0.7.7.tgz#5f107cbd99c8c6362d869e0ac99e85b8c59aceab" -ng2-smart-table@1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/ng2-smart-table/-/ng2-smart-table-1.0.3.tgz#259f12564044aa87f6a86885fa16fbe6be8c2439" +ng2-smart-table@1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/ng2-smart-table/-/ng2-smart-table-1.2.1.tgz#b25102c1a8b0588c508cf913c539ddf0f0b3341d" dependencies: lodash "^4.17.4" ng2-completer "^1.2.2" -ng2-tag-input@1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/ng2-tag-input/-/ng2-tag-input-1.0.5.tgz#cb1391a6ae8ca6c53f0143c04513d1e16bd6b476" +ng2-tag-input@1.3.3: + version "1.3.3" + resolved "https://registry.yarnpkg.com/ng2-tag-input/-/ng2-tag-input-1.3.3.tgz#612b12b244dfd1efdb9659fd99caafa16762ff56" dependencies: ng2-material-dropdown "0.7.7" @@ -3544,12 +3648,20 @@ object.omit@^2.0.0: for-own "^0.1.4" is-extendable "^0.1.1" +obuf@^1.0.0, obuf@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/obuf/-/obuf-1.1.1.tgz#104124b6c602c6796881a042541d36db43a5264e" + on-finished@~2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" dependencies: ee-first "1.1.1" +on-headers@~1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/on-headers/-/on-headers-1.0.1.tgz#928f5d0f470d49342651ea6794b0857c100693f7" + once@^1.3.0, once@^1.3.1, once@^1.3.3, once@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" @@ -3564,6 +3676,13 @@ opener@^1.4.3: version "1.4.3" resolved "https://registry.yarnpkg.com/opener/-/opener-1.4.3.tgz#5c6da2c5d7e5831e8ffa3964950f8d6674ac90b8" +opn@4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/opn/-/opn-4.0.2.tgz#7abc22e644dff63b0a96d5ab7f2790c0f01abc95" + dependencies: + object-assign "^4.0.1" + pinkie-promise "^2.0.0" + optimize-js-plugin@0.0.4: version "0.0.4" resolved "https://registry.yarnpkg.com/optimize-js-plugin/-/optimize-js-plugin-0.0.4.tgz#69e7a67e0f66c69f7fc0c7b25c5d33b2db6c2817" @@ -3592,6 +3711,12 @@ optionator@^0.8.2: type-check "~0.3.2" wordwrap "~1.0.0" +original@>=0.0.5: + version "1.0.0" + resolved "https://registry.yarnpkg.com/original/-/original-1.0.0.tgz#9147f93fa1696d04be61e01bd50baeaca656bd3b" + dependencies: + url-parse "1.0.x" + os-browserify@^0.2.0: version "0.2.1" resolved "https://registry.yarnpkg.com/os-browserify/-/os-browserify-0.2.1.tgz#63fc4ccee5d2d7763d26bbf8601078e6c2e0044f" @@ -3800,6 +3925,14 @@ pluralize@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-1.2.1.tgz#d1a21483fd22bb41e58a12fa3421823140897c45" +portfinder@^1.0.9: + version "1.0.13" + resolved "https://registry.yarnpkg.com/portfinder/-/portfinder-1.0.13.tgz#bb32ecd87c27104ae6ee44b5a3ccbf0ebb1aede9" + dependencies: + async "^1.5.2" + debug "^2.2.0" + mkdirp "0.5.x" + postcss-calc@^5.2.0: version "5.3.1" resolved "https://registry.yarnpkg.com/postcss-calc/-/postcss-calc-5.3.1.tgz#77bae7ca928ad85716e2fda42f261bf7c1d65b5e" @@ -4167,6 +4300,14 @@ querystring@0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620" +querystringify@0.0.x: + version "0.0.4" + resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-0.0.4.tgz#0cf7f84f9463ff0ae51c4c4b142d95be37724d9c" + +querystringify@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-1.0.0.tgz#6286242112c5b712fa654e526652bf6a13ff05cb" + random-access-file@^1.0.1: version "1.8.1" resolved "https://registry.yarnpkg.com/random-access-file/-/random-access-file-1.8.1.tgz#b1a54a0f924fbd4d45731a5771aea36be2166532" @@ -4194,7 +4335,7 @@ randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.3: dependencies: safe-buffer "^5.1.0" -range-parser@^1.2.0, range-parser@~1.2.0: +range-parser@^1.0.3, range-parser@^1.2.0, range-parser@~1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.0.tgz#f49be6b487894ddc40dcc94a322f611092e00d5e" @@ -4242,7 +4383,7 @@ readable-stream@1.0: isarray "0.0.1" string_decoder "~0.10.x" -readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.3, readable-stream@^2.0.4, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.1.4, readable-stream@^2.2.2, readable-stream@^2.2.6: +readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.3, readable-stream@^2.0.4, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.1.4, readable-stream@^2.2.2, readable-stream@^2.2.6, readable-stream@^2.2.9: version "2.2.11" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.2.11.tgz#0796b31f8d7688007ff0b93a8088d34aa17c0f72" dependencies: @@ -4438,6 +4579,10 @@ require-uncached@^1.0.2: caller-path "^0.1.0" resolve-from "^1.0.0" +requires-port@1.0.x, requires-port@1.x.x: + version "1.0.0" + resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" + resolve-from@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226" @@ -4606,6 +4751,10 @@ scss-tokenizer@^0.2.3: js-base64 "^2.1.8" source-map "^0.4.2" +select-hose@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/select-hose/-/select-hose-2.0.0.tgz#625d8658f865af43ec962bfc376a37359a4994ca" + semver-dsl@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/semver-dsl/-/semver-dsl-1.0.1.tgz#d3678de5555e8a61f629eed025366ae5f27340a0" @@ -4634,6 +4783,18 @@ send@0.15.3: range-parser "~1.2.0" statuses "~1.3.1" +serve-index@^1.7.2: + version "1.9.0" + resolved "https://registry.yarnpkg.com/serve-index/-/serve-index-1.9.0.tgz#d2b280fc560d616ee81b48bf0fa82abed2485ce7" + dependencies: + accepts "~1.3.3" + batch "0.6.1" + debug "2.6.8" + escape-html "~1.0.3" + http-errors "~1.6.1" + mime-types "~2.1.15" + parseurl "~1.3.1" + serve-static@1.12.3: version "1.12.3" resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.12.3.tgz#9f4ba19e2f3030c547f8af99107838ec38d5b1e2" @@ -4747,6 +4908,24 @@ sntp@1.x.x: dependencies: hoek "2.x.x" +sockjs-client@1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/sockjs-client/-/sockjs-client-1.1.2.tgz#f0212a8550e4c9468c8cceaeefd2e3493c033ad5" + dependencies: + debug "^2.2.0" + eventsource "0.1.6" + faye-websocket "~0.11.0" + inherits "^2.0.1" + json3 "^3.3.2" + url-parse "^1.1.1" + +sockjs@0.3.18: + version "0.3.18" + resolved "https://registry.yarnpkg.com/sockjs/-/sockjs-0.3.18.tgz#d9b289316ca7df77595ef299e075f0f937eb4207" + dependencies: + faye-websocket "^0.10.0" + uuid "^2.0.2" + sort-keys@^1.0.0: version "1.1.2" resolved "https://registry.yarnpkg.com/sort-keys/-/sort-keys-1.1.2.tgz#441b6d4d346798f1b4e49e8920adfba0e543f9ad" @@ -4818,6 +4997,29 @@ spdx-license-ids@^1.0.2: version "1.2.2" resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz#c9df7a3424594ade6bd11900d596696dc06bac57" +spdy-transport@^2.0.18: + version "2.0.20" + resolved "https://registry.yarnpkg.com/spdy-transport/-/spdy-transport-2.0.20.tgz#735e72054c486b2354fe89e702256004a39ace4d" + dependencies: + debug "^2.6.8" + detect-node "^2.0.3" + hpack.js "^2.1.6" + obuf "^1.1.1" + readable-stream "^2.2.9" + safe-buffer "^5.0.1" + wbuf "^1.7.2" + +spdy@^3.4.1: + version "3.4.7" + resolved "https://registry.yarnpkg.com/spdy/-/spdy-3.4.7.tgz#42ff41ece5cc0f99a3a6c28aabb73f5c3b03acbc" + dependencies: + debug "^2.6.8" + handle-thing "^1.2.5" + http-deceiver "^1.2.7" + safe-buffer "^5.0.1" + select-hose "^2.0.0" + spdy-transport "^2.0.18" + speedometer@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/speedometer/-/speedometer-1.0.0.tgz#cd671cb06752c22bca3370e2f334440be4fc62e2" @@ -5006,7 +5208,7 @@ supports-color@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" -supports-color@^3.1.0, supports-color@^3.2.3: +supports-color@^3.1.0, supports-color@^3.1.1, supports-color@^3.2.3: version "3.2.3" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.2.3.tgz#65ac0504b3954171d8a64946b2ae3cbb8a5f54f6" dependencies: @@ -5337,6 +5539,20 @@ url-loader@^0.5.7: loader-utils "^1.0.2" mime "1.3.x" +url-parse@1.0.x: + version "1.0.5" + resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.0.5.tgz#0854860422afdcfefeb6c965c662d4800169927b" + dependencies: + querystringify "0.0.x" + requires-port "1.0.x" + +url-parse@^1.1.1: + version "1.1.9" + resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.1.9.tgz#c67f1d775d51f0a18911dd7b3ffad27bb9e5bd19" + dependencies: + querystringify "~1.0.0" + requires-port "1.0.x" + url@^0.11.0: version "0.11.0" resolved "https://registry.yarnpkg.com/url/-/url-0.11.0.tgz#3838e97cfc60521eb73c525a8e55bfdd9e2e28f1" @@ -5396,6 +5612,10 @@ utils-merge@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.0.tgz#0294fb922bb9375153541c4f7096231f287c8af8" +uuid@^2.0.2: + version "2.0.3" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-2.0.3.tgz#67e2e863797215530dff318e5bf9dcebfd47b21a" + uuid@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.0.1.tgz#6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1" @@ -5413,7 +5633,7 @@ validate-npm-package-license@^3.0.1: spdx-correct "~1.0.0" spdx-expression-parse "~1.0.0" -vary@~1.1.1: +vary@~1.1.0, vary@~1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.1.tgz#67535ebb694c1d52257457984665323f587e8d37" @@ -5497,6 +5717,12 @@ watchpack@^1.3.1: chokidar "^1.4.3" graceful-fs "^4.1.2" +wbuf@^1.1.0, wbuf@^1.7.2: + version "1.7.2" + resolved "https://registry.yarnpkg.com/wbuf/-/wbuf-1.7.2.tgz#d697b99f1f59512df2751be42769c1580b5801fe" + dependencies: + minimalistic-assert "^1.0.0" + webpack-bundle-analyzer@^2.8.2: version "2.8.2" resolved "https://registry.yarnpkg.com/webpack-bundle-analyzer/-/webpack-bundle-analyzer-2.8.2.tgz#8b6240c29a9d63bc72f09d920fb050adbcce9fe8" @@ -5513,6 +5739,37 @@ webpack-bundle-analyzer@^2.8.2: opener "^1.4.3" ws "^2.3.1" +webpack-dev-middleware@^1.10.2: + version "1.10.2" + resolved "https://registry.yarnpkg.com/webpack-dev-middleware/-/webpack-dev-middleware-1.10.2.tgz#2e252ce1dfb020dbda1ccb37df26f30ab014dbd1" + dependencies: + memory-fs "~0.4.1" + mime "^1.3.4" + path-is-absolute "^1.0.0" + range-parser "^1.0.3" + +webpack-dev-server@^2.4.5: + version "2.4.5" + resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-2.4.5.tgz#31384ce81136be1080b4b4cde0eb9b90e54ee6cf" + dependencies: + ansi-html "0.0.7" + chokidar "^1.6.0" + compression "^1.5.2" + connect-history-api-fallback "^1.3.0" + express "^4.13.3" + html-entities "^1.2.0" + http-proxy-middleware "~0.17.4" + opn "4.0.2" + portfinder "^1.0.9" + serve-index "^1.7.2" + sockjs "0.3.18" + sockjs-client "1.1.2" + spdy "^3.4.1" + strip-ansi "^3.0.0" + supports-color "^3.1.1" + webpack-dev-middleware "^1.10.2" + yargs "^6.0.0" + webpack-dll-bundles-plugin@^1.0.0-beta.5: version "1.0.0-beta.5" resolved "https://registry.yarnpkg.com/webpack-dll-bundles-plugin/-/webpack-dll-bundles-plugin-1.0.0-beta.5.tgz#cfb109710a88c3eeb557fcc38be0c5015a54196d" @@ -5574,6 +5831,16 @@ webpack@^2.6.0: webpack-sources "^0.2.3" yargs "^6.0.0" +websocket-driver@>=0.5.1: + version "0.6.5" + resolved "https://registry.yarnpkg.com/websocket-driver/-/websocket-driver-0.6.5.tgz#5cb2556ceb85f4373c6d8238aa691c8454e13a36" + dependencies: + websocket-extensions ">=0.1.1" + +websocket-extensions@>=0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/websocket-extensions/-/websocket-extensions-0.1.1.tgz#76899499c184b6ef754377c2dbb0cd6cb55d29e7" + webtorrent@^0.98.0: version "0.98.18" resolved "https://registry.yarnpkg.com/webtorrent/-/webtorrent-0.98.18.tgz#d8e0e04a52af884e9cffa361cbe8c159a4cb6f98" diff --git a/package.json b/package.json index 2dd6e7666..83ea17638 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ "help": "scripty", "postinstall": "cd client && yarn install", "tsc": "tsc", - "nodemon": "nodemon" + "nodemon": "nodemon", + "ts-node": "ts-node" }, "dependencies": { "async": "^2.0.0", @@ -74,6 +75,7 @@ "safe-buffer": "^5.0.1", "scripty": "^1.5.0", "sequelize": "4.0.0-2", + "ts-node": "^3.0.6", "typescript": "~2.2.0", "validator": "^7.0.0", "winston": "^2.1.1", diff --git a/scripts/danger/clean/cleaner.js b/scripts/danger/clean/cleaner.ts similarity index 55% rename from scripts/danger/clean/cleaner.js rename to scripts/danger/clean/cleaner.ts index 1a1e3dee7..d1dba4650 100644 --- a/scripts/danger/clean/cleaner.js +++ b/scripts/danger/clean/cleaner.ts @@ -1,16 +1,16 @@ -const eachSeries = require('async/eachSeries') -const rimraf = require('rimraf') +import * as eachSeries from 'async/eachSeries' +import * as rimraf from 'rimraf' -const constants = require('../../../server/initializers/constants') -const db = require('../../../server/initializers/database') +import { CONFIG } from '../../../server/initializers/constants' +import { database as db } from '../../../server/initializers/database' db.init(true, function () { db.sequelize.drop().asCallback(function (err) { if (err) throw err - console.info('Tables of %s deleted.', db.sequelize.config.database) + console.info('Tables of %s deleted.', CONFIG.DATABASE.DBNAME) - const STORAGE = constants.CONFIG.STORAGE + const STORAGE = CONFIG.STORAGE eachSeries(Object.keys(STORAGE), function (storage, callbackEach) { const storageDir = STORAGE[storage] diff --git a/scripts/danger/clean/dev.sh b/scripts/danger/clean/dev.sh index f4a5d1e8a..270ca0a2e 100755 --- a/scripts/danger/clean/dev.sh +++ b/scripts/danger/clean/dev.sh @@ -4,5 +4,5 @@ read -p "This will remove all directories and SQL tables. Are you sure? (y/*) " echo if [[ "$REPLY" =~ ^[Yy]$ ]]; then - NODE_ENV=test node "./scripts/danger/clean/cleaner" + NODE_ENV=test npm run ts-node "./scripts/danger/clean/cleaner" fi diff --git a/scripts/watch/client.sh b/scripts/watch/client.sh index 3e4522547..c99ed14e6 100755 --- a/scripts/watch/client.sh +++ b/scripts/watch/client.sh @@ -2,4 +2,4 @@ cd client || exit -1 -npm run webpack -- --config config/webpack.dev.js --progress --profile --colors --display-error-details --display-cached --watch +npm run webpack-dev-server -- --config config/webpack.dev.js --progress --profile --colors --watch --content-base src/ --inline --hot diff --git a/server.ts b/server.ts index b27a83860..60045865d 100644 --- a/server.ts +++ b/server.ts @@ -1,4 +1,6 @@ -if ([ 'dev', 'test'].indexOf(process.env.NODE_ENV) !== -1) { +import { isTestInstance } from './server/helpers/core-utils' + +if (isTestInstance()) { require('source-map-support').install() } @@ -11,6 +13,7 @@ import * as http from 'http' import * as morgan from 'morgan' import * as path from 'path' import * as bittorrentTracker from 'bittorrent-tracker' +import * as cors from 'cors' import { Server as WebSocketServer } from 'ws' const TrackerServer = bittorrentTracker.Server @@ -56,6 +59,14 @@ import { apiRouter, clientsRouter, staticRouter } from './server/controllers' // ----------- App ----------- +// Enable cors for develop +if (isTestInstance()) { + app.use(cors({ + origin: 'http://localhost:3000', + credentials: true + })) +} + // For the logger app.use(morgan('combined', { stream: { write: logger.info } diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index bfa018031..3b2ac4a6c 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts @@ -86,7 +86,6 @@ videosRouter.get('/', ) videosRouter.put('/:id', authenticate, - reqFiles, videosUpdateValidator, updateVideoRetryWrapper ) diff --git a/server/helpers/core-utils.ts b/server/helpers/core-utils.ts new file mode 100644 index 000000000..32b89b6dd --- /dev/null +++ b/server/helpers/core-utils.ts @@ -0,0 +1,22 @@ +/* + Different from 'utils' because we don't not import other PeerTube modules. + Useful to avoid circular dependencies. +*/ + +import { join } from 'path' + +function isTestInstance () { + return process.env.NODE_ENV === 'test' +} + +function root () { + // We are in /dist/helpers/utils.js + return join(__dirname, '..', '..', '..') +} + +// --------------------------------------------------------------------------- + +export { + isTestInstance, + root +} diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts index c5ef4cb5f..8904975c0 100644 --- a/server/helpers/custom-validators/videos.ts +++ b/server/helpers/custom-validators/videos.ts @@ -1,5 +1,6 @@ import { values } from 'lodash' import * as validator from 'validator' +import 'multer' import { CONSTRAINTS_FIELDS, diff --git a/server/helpers/index.ts b/server/helpers/index.ts index e56bd21ad..78215fe10 100644 --- a/server/helpers/index.ts +++ b/server/helpers/index.ts @@ -1,3 +1,4 @@ +export * from './core-utils' export * from './logger' export * from './custom-validators' export * from './database-utils' diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts index 1dcbd31c4..8e489de96 100644 --- a/server/helpers/utils.ts +++ b/server/helpers/utils.ts @@ -23,10 +23,6 @@ function createEmptyCallback () { } } -function isTestInstance () { - return process.env.NODE_ENV === 'test' -} - function getFormatedObjects (objects: any[], objectsTotal: number) { const formatedObjects = [] @@ -40,18 +36,11 @@ function getFormatedObjects (objects: any[], objectsTotal: number) { } } -function root () { - // We are in /dist/helpers/utils.js - return join(__dirname, '..', '..', '..') -} - // --------------------------------------------------------------------------- export { badRequest, createEmptyCallback, generateRandomString, - isTestInstance, - getFormatedObjects, - root + getFormatedObjects } diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 6dcb4bb91..b476ef928 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -2,7 +2,7 @@ import * as config from 'config' import { join } from 'path' // Do not use barrels, remain constants as independent as possible -import { root, isTestInstance } from '../helpers/utils' +import { root, isTestInstance } from '../helpers/core-utils' // --------------------------------------------------------------------------- diff --git a/server/initializers/database.ts b/server/initializers/database.ts index 78ca5ab84..0ab9e98db 100644 --- a/server/initializers/database.ts +++ b/server/initializers/database.ts @@ -5,7 +5,7 @@ import * as Sequelize from 'sequelize' import { CONFIG } from './constants' // Do not use barrel, we need to load database first import { logger } from '../helpers/logger' -import { isTestInstance } from '../helpers/utils' +import { isTestInstance } from '../helpers/core-utils' import { ApplicationModel, AuthorModel, @@ -80,9 +80,9 @@ database.init = function (silent: boolean, callback: (err: Error) => void) { files.filter(function (file) { // For all models but not utils.js if ( - file === 'index.js' || - file === 'utils.js' || - file.endsWith('-interface.js') || + file === 'index.js' || file === 'index.ts' || + file === 'utils.js' || file === 'utils.ts' || + file.endsWith('-interface.js') || file.endsWith('-interface.ts') || file.endsWith('.js.map') ) return false diff --git a/yarn.lock b/yarn.lock index 5b2fe58e9..a4f880cc2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -944,7 +944,7 @@ dicer@0.2.5: readable-stream "1.1.x" streamsearch "0.1.2" -diff@3.2.0, diff@^3.2.0: +diff@3.2.0, diff@^3.1.0, diff@^3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/diff/-/diff-3.2.0.tgz#c9ce393a4b7cbd0b058a725c93df299027868ff9" @@ -2258,6 +2258,10 @@ magnet-uri@^5.1.3, magnet-uri@^5.1.4: uniq "^1.0.1" xtend "^4.0.0" +make-error@^1.1.1: + version "1.3.0" + resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.0.tgz#52ad3a339ccf10ce62b4040b708fe707244b8b96" + map-stream@~0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/map-stream/-/map-stream-0.1.0.tgz#e56aa94c4c8055a16404a0674b78f215f7c8e194" @@ -3395,7 +3399,7 @@ sntp@1.x.x: dependencies: hoek "2.x.x" -source-map-support@^0.4.15: +source-map-support@^0.4.0, source-map-support@^0.4.15: version "0.4.15" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.15.tgz#03202df65c06d2bd8c7ec2362a193056fef8d3b1" dependencies: @@ -3574,7 +3578,7 @@ strip-bom@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" -strip-json-comments@~2.0.1: +strip-json-comments@^2.0.0, strip-json-comments@~2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" @@ -3751,6 +3755,28 @@ tryit@^1.0.1: version "1.0.3" resolved "https://registry.yarnpkg.com/tryit/-/tryit-1.0.3.tgz#393be730a9446fd1ead6da59a014308f36c289cb" +ts-node@^3.0.6: + version "3.0.6" + resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-3.0.6.tgz#55127ff790c7eebf6ba68c1e6dde94b09aaa21e0" + dependencies: + arrify "^1.0.0" + chalk "^1.1.1" + diff "^3.1.0" + make-error "^1.1.1" + minimist "^1.2.0" + mkdirp "^0.5.1" + source-map-support "^0.4.0" + tsconfig "^6.0.0" + v8flags "^2.0.11" + yn "^2.0.0" + +tsconfig@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/tsconfig/-/tsconfig-6.0.0.tgz#6b0e8376003d7af1864f8df8f89dd0059ffcd032" + dependencies: + strip-bom "^3.0.0" + strip-json-comments "^2.0.0" + tslib@^1.0.0, tslib@^1.7.1: version "1.7.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.7.1.tgz#bc8004164691923a79fe8378bbeb3da2017538ec" @@ -3897,6 +3923,10 @@ upper-case@^1.1.1: version "1.1.3" resolved "https://registry.yarnpkg.com/upper-case/-/upper-case-1.1.3.tgz#f6b4501c2ec4cdd26ba78be7222961de77621598" +user-home@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/user-home/-/user-home-1.1.1.tgz#2b5be23a32b63a7c9deb8d0f28d485724a3df190" + user-home@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/user-home/-/user-home-2.0.0.tgz#9c70bfd8169bc1dcbf48604e0f04b8b49cde9e9f" @@ -3939,6 +3969,12 @@ uuid@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.0.1.tgz#6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1" +v8flags@^2.0.11: + version "2.1.1" + resolved "https://registry.yarnpkg.com/v8flags/-/v8flags-2.1.1.tgz#aab1a1fa30d45f88dd321148875ac02c0b55e5b4" + dependencies: + user-home "^1.1.1" + validator.js@^1.1.1: version "1.2.3" resolved "https://registry.yarnpkg.com/validator.js/-/validator.js-1.2.3.tgz#f8e623f60e53bada54880333649970996a3446e1" @@ -4099,6 +4135,10 @@ yallist@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" +yn@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/yn/-/yn-2.0.0.tgz#e5adabc8acf408f6385fc76495684c88e6af689a" + zero-fill@^2.2.3: version "2.2.3" resolved "https://registry.yarnpkg.com/zero-fill/-/zero-fill-2.2.3.tgz#a3def06ba5e39ae644850bb4ca2ad4112b4855e9"