crobi пре 10 година
родитељ
комит
9e25c9528d

+ 1076
- 0
server/external/express/express.d.ts
Разлика између датотеке није приказан због своје велике величине
Прегледај датотеку


+ 19
- 0
server/external/mime/mime.d.ts Прегледај датотеку

@@ -0,0 +1,19 @@
1
+// Type definitions for mime
2
+// Project: https://github.com/broofa/node-mime
3
+// Definitions by: Jeff Goddard <https://github.com/jedigo>
4
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
5
+
6
+// Imported from: https://github.com/soywiz/typescript-node-definitions/mime.d.ts
7
+
8
+declare module "mime" {
9
+	export function lookup(path: string): string;
10
+	export function extension(mime: string): string;
11
+	export function load(filepath: string): void;
12
+	export function define(mimes: Object): void;
13
+
14
+	interface Charsets {
15
+		lookup(mime: string): string;
16
+	}
17
+
18
+	export var charsets: Charsets;
19
+}

+ 2069
- 0
server/external/node/node.d.ts
Разлика између датотеке није приказан због своје велике величине
Прегледај датотеку


+ 86
- 0
server/external/serve-static/serve-static.d.ts Прегледај датотеку

@@ -0,0 +1,86 @@
1
+// Type definitions for serve-static 1.7.1
2
+// Project: https://github.com/expressjs/serve-static
3
+// Definitions by: Uros Smolnik <https://github.com/urossmolnik/>
4
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
5
+
6
+/* =================== USAGE ===================
7
+
8
+    import serveStatic = require('serve-static');
9
+    app.use(serveStatic('public/ftp', {'index': ['default.html', 'default.htm']}))
10
+
11
+ =============================================== */
12
+
13
+/// <reference path="../express/express.d.ts" />
14
+/// <reference path="../mime/mime.d.ts" />
15
+
16
+declare module "serve-static" {
17
+    import * as express from "express";
18
+    
19
+    /**
20
+     * Create a new middleware function to serve files from within a given root directory. 
21
+     * The file to serve will be determined by combining req.url with the provided root directory. 
22
+     * When a file is not found, instead of sending a 404 response, this module will instead call next() to move on to the next middleware, allowing for stacking and fall-backs.
23
+     */
24
+    function serveStatic(root: string, options?: {
25
+        /**
26
+        * Set how "dotfiles" are treated when encountered. A dotfile is a file or directory that begins with a dot ("."). 
27
+        * Note this check is done on the path itself without checking if the path actually exists on the disk. 
28
+        * If root is specified, only the dotfiles above the root are checked (i.e. the root itself can be within a dotfile when when set to "deny").
29
+        * The default value is 'ignore'.
30
+        * 'allow' No special treatment for dotfiles
31
+        * 'deny' Send a 403 for any request for a dotfile
32
+        * 'ignore' Pretend like the dotfile does not exist and call next()
33
+        */
34
+        dotfiles?: string;
35
+
36
+        /**
37
+         * Enable or disable etag generation, defaults to true.
38
+         */
39
+        etag?: boolean;
40
+
41
+        /**
42
+         * Set file extension fallbacks. When set, if a file is not found, the given extensions will be added to the file name and search for.
43
+         * The first that exists will be served. Example: ['html', 'htm'].
44
+         * The default value is false.
45
+         */
46
+        extensions?: string[];
47
+
48
+        /**
49
+         * By default this module will send "index.html" files in response to a request on a directory.
50
+         * To disable this set false or to supply a new index pass a string or an array in preferred order.
51
+         */
52
+        index?: boolean;
53
+
54
+        /**
55
+         * Enable or disable Last-Modified header, defaults to true. Uses the file system's last modified value.
56
+         */
57
+        lastModified?: boolean;
58
+
59
+        /**
60
+         * Provide a max-age in milliseconds for http caching, defaults to 0. This can also be a string accepted by the ms module.
61
+         */
62
+        maxAge?: number;
63
+
64
+        /**
65
+         * Redirect to trailing "/" when the pathname is a dir. Defaults to true.
66
+         */
67
+        redirect?: boolean;
68
+
69
+        /**
70
+         * Function to set custom headers on response. Alterations to the headers need to occur synchronously.
71
+         * The function is called as fn(res, path, stat), where the arguments are:
72
+         * res the response object
73
+         * path the file path that is being sent
74
+         * stat the stat object of the file that is being sent
75
+         */
76
+        setHeaders?: (res: express.Response, path: string, stat: any) => any;
77
+    }): express.Handler;
78
+
79
+    import * as m from "mime";
80
+
81
+    module serveStatic {
82
+        var mime: typeof m;
83
+    }
84
+
85
+    export = serveStatic;
86
+}

+ 20
- 0
server/gulpfile.js Прегледај датотеку

@@ -0,0 +1,20 @@
1
+var gulp       = require('gulp')
2
+  , ts         = require('gulp-typescript')
3
+  ;
4
+
5
+var tsProject = ts.createProject({
6
+    declarationFiles: false,
7
+    target: 'ES6',
8
+    typescript: require('typescript')
9
+});
10
+
11
+gulp.task('default', function() {
12
+    return gulp.src(['server.ts'], { base: './' })
13
+        .pipe(ts(tsProject)).js
14
+        .pipe(gulp.dest('./'))
15
+        ;
16
+});
17
+
18
+gulp.task('watch', ['default'], function() {
19
+    gulp.watch('src/**/*.ts', ['default']);
20
+});

+ 9
- 1
server/package.json Прегледај датотеку

@@ -6,11 +6,19 @@
6 6
   "main": "js/app.js",
7 7
   "scripts": {
8 8
     "test": "echo \"Error: no test specified\" && exit 1",
9
-    "start": "node ./node_modules/http-server/bin/http-server ../client -o"
9
+    "start": "node ./server.js"
10 10
   },
11 11
   "author": "crobi",
12 12
   "dependencies": {
13 13
     "http-server": "*"
14 14
   },
15
+  "devDependencies": {
16
+    "typescript": "1.5.x",
17
+    "gulp": "*",
18
+    "gulp-typescript": "*",
19
+    "connect": "3.x",
20
+    "serve-static": "*",
21
+    "morgan": "*"
22
+  },
15 23
   "license": "BSD-2-Clause"
16 24
 }

+ 12
- 0
server/server.js Прегледај датотеку

@@ -0,0 +1,12 @@
1
+/// <reference path="./external/node/node.d.ts" />
2
+/// <reference path="./external/serve-static/serve-static.d.ts" />
3
+var connect = require('connect'), morgan = require('morgan'), serveStatic = require('serve-static');
4
+var app = connect()
5
+    .use(morgan('tiny'))
6
+    .use(serveStatic('../client/'))
7
+    .use(function (req, res, next) {
8
+    req.url = './index.html';
9
+    next();
10
+})
11
+    .use(serveStatic('../client/'))
12
+    .listen(8080);

+ 17
- 0
server/server.ts Прегледај датотеку

@@ -0,0 +1,17 @@
1
+/// <reference path="./external/node/node.d.ts" />
2
+/// <reference path="./external/serve-static/serve-static.d.ts" />
3
+
4
+
5
+var connect     = require('connect')
6
+  , morgan      = require('morgan')
7
+  , serveStatic = require('serve-static');
8
+
9
+var app = connect()
10
+    .use(morgan('tiny'))
11
+    .use(serveStatic('../client/'))
12
+    .use(function(req: any, res: any, next: any) {
13
+        req.url = './index.html';
14
+        next();
15
+    })
16
+    .use(serveStatic('../client/'))
17
+    .listen(8080);

+ 20
- 0
server/tsconfig.json Прегледај датотеку

@@ -0,0 +1,20 @@
1
+{
2
+    "version": "1.5.0-alpha",
3
+    "compilerOptions": {
4
+        "target": "es6",
5
+        "declaration": false,
6
+        "noImplicitAny": true,
7
+        "removeComments": true,
8
+        "noLib": false,
9
+        "preserveConstEnums": true,
10
+        "suppressImplicitAnyIndexErrors": true,
11
+        "out": "./server.js"
12
+    },
13
+    "filesGlob": [
14
+        "./**/*.ts",
15
+        "!./node_modules/**/*.ts"
16
+    ],
17
+    "files": [
18
+        "./server.ts"
19
+    ]
20
+}

Loading…
Откажи
Сачувај