Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions imageboard/ImageBoard.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props')" />
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">12.0</VisualStudioVersion>
<TypeScriptToolsVersion>1.4</TypeScriptToolsVersion>
</PropertyGroup>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand All @@ -18,6 +23,8 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TypeScriptRemoveComments>false</TypeScriptRemoveComments>
<TypeScriptSourceMap>true</TypeScriptSourceMap>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -26,6 +33,8 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TypeScriptRemoveComments>false</TypeScriptRemoveComments>
<TypeScriptSourceMap>true</TypeScriptSourceMap>
</PropertyGroup>
<PropertyGroup>
<RootNamespace>ImageBoard</RootNamespace>
Expand All @@ -40,15 +49,16 @@
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<None Include="app.ts" />
<None Include="db.ts" />
<None Include="mongodb.ts" />
<TypeScriptCompile Include="app.ts" />
<TypeScriptCompile Include="db.ts" />
<None Include="package.json" />
<None Include="routes\index.ts" />
<TypeScriptCompile Include="routes\index.ts" />
<None Include="views\board.jade" />
<None Include="views\image.jade" />
<None Include="views\index.jade" />
<None Include="views\layout.jade" />
<None Include="views\newboard.jade" />
<None Include="views\newpin.jade" />
<None Include="views\user.jade" />
</ItemGroup>
<ItemGroup>
Expand All @@ -58,8 +68,18 @@
<Folder Include="public\images\" />
<Folder Include="public\javascripts\" />
</ItemGroup>
<ItemGroup>
<TypeScriptCompile Include="typings\express\express-middleware.d.ts" />
<TypeScriptCompile Include="typings\express\express.d.ts" />
<TypeScriptCompile Include="typings\mongodb\mongodb.d.ts" />
<TypeScriptCompile Include="typings\node\node.d.ts" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSHARP.Targets" />
<ProjectExtensions>
<VisualStudio AllowExistingFolder="true" />
</ProjectExtensions>
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<TypeScriptModuleKind>commonjs</TypeScriptModuleKind>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets')" />
</Project>
39 changes: 23 additions & 16 deletions imageboard/app.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
///<reference path='../node/node.d.ts' />
/// <reference path='typings/node/node.d.ts' />
/// <reference path='typings/mongodb/mongodb.d.ts' />
/// <reference path='typings/express/express.d.ts' />
/// <reference path='typings/express/express-middleware.d.ts' />


import http = require("http")
import url = require("url")
import routes = require("./routes/index")
import db = require("./db")
import express = require("express")
import bodyParser = require("body-parser");
import methodOverride = require("method-override");
import errorHandler = require("errorhandler");

var app = express();

// Configuration
app.configure(function(){
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.set('view options', { layout: false });
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.static(__dirname + '/public'));
});

app.configure('development', function(){
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.set('view options', { layout: false });
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(methodOverride());
app.use(express.static(__dirname + '/public'));

app.configure('production', function(){
app.use(express.errorHandler());
});
var env = process.env.NODE_ENV || 'development';
if (env === 'development') {
app.use(errorHandler({ dumpExceptions: true, showStack: true }));
}
else if (env === 'production') {
app.use(errorHandler());
}


// Routes
Expand Down Expand Up @@ -94,7 +101,7 @@ app.get('/user/:userid/:boardid', function(req, res) {
});
});
} else {
res.send('not found', 404);
res.send(404, 'not found');
}
});
});
Expand Down
4 changes: 2 additions & 2 deletions imageboard/db.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Mongo
import mongodb = require('mongodb');

var server = new mongodb.Server('localhost', 27017, {auto_reconnect: true}, {})
var db = new mongodb.Db('mydb', server);
var server = new mongodb.Server('localhost', 27017, {auto_reconnect: true})
var db = new mongodb.Db('mydb', server, { w: 1 });
db.open(function() {});

export interface User {
Expand Down
128 changes: 0 additions & 128 deletions imageboard/express.d.ts

This file was deleted.

33 changes: 0 additions & 33 deletions imageboard/mongodb.ts

This file was deleted.

19 changes: 11 additions & 8 deletions imageboard/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
{
"name": "application-name"
, "version": "0.0.1"
, "private": true
, "dependencies": {
"express": ">= 3.0.0"
, "ejs": ">= 0.5.0"
, "jade": ">= 0.0.1"
, "mongodb": ">= 1.0.0"
"name": "imageboard-sample",
"version": "0.0.1",
"private": true,
"dependencies": {
"express": "4.11.1",
"body-parser": "1.10.2",
"errorhandler": "1.3.2",
"method-override": "2.3.1",
"ejs": ">= 0.5.0",
"jade": ">= 0.0.1",
"mongodb": ">= 1.4.29"
}
}
2 changes: 1 addition & 1 deletion imageboard/routes/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import express = require("express")
import db = require("../db")

export function index(req: express.ExpressServerRequest, res: express.ExpressServerResponse){
export function index(req: express.Request, res: express.Response) {
db.getUsers(function(users) {
console.dir(users);
res.render('index', { title: 'ImageBoard', users: users })
Expand Down
23 changes: 23 additions & 0 deletions imageboard/typings/express/express-middleware.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/// <reference path="express.d.ts" />

declare module "body-parser" {
import express = require("express");
function bodyParser(): express.RequestHandler;
module bodyParser {
function urlencoded(opts?: any): express.RequestHandler;
function json(): express.RequestHandler;
}
export = bodyParser;
}

declare module "method-override" {
import express = require("express");
function methodOverride(): express.RequestHandler;
export = methodOverride;
}

declare module "errorhandler" {
import express = require("express");
function errorHandler(opts?: any): express.ErrorRequestHandler;
export = errorHandler;
}
Loading