isundil 4 年之前
父節點
當前提交
45fe3a272b

+ 9 - 0
.gitignore

@@ -0,0 +1,9 @@
+.vs/
+bin/
+obj/
+*.map
+package-lock.json
+/ACPSBooking/routes/*.js
+/ACPSBooking/src/*.js
+/ACPSBooking/server.js
+/ACPSBooking/node_modules/

+ 96 - 0
ACPSBooking/ACPSBooking.njsproj

@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+  <PropertyGroup>
+    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
+    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
+    <Name>ACPSBooking</Name>
+    <RootNamespace>ACPSBooking</RootNamespace>
+  </PropertyGroup>
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>b56ac31b-68e5-45fd-a7bc-5d1ca27cc3aa</ProjectGuid>
+    <ProjectHome>.</ProjectHome>
+    <StartupFile>server.ts</StartupFile>
+    <StartWebBrowser>True</StartWebBrowser>
+    <SearchPath>
+    </SearchPath>
+    <WorkingDirectory>.</WorkingDirectory>
+    <OutputPath>.</OutputPath>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <ProjectTypeGuids>{3AF33F2E-1136-4D97-BBB7-1795711AC8B8};{349c5851-65df-11da-9384-00065b846f21};{9092AA53-FB77-4645-B42D-1CCCA6BD08BD}</ProjectTypeGuids>
+    <NodejsPort>1337</NodejsPort>
+    <EnableTypeScript>true</EnableTypeScript>
+    <StartWebBrowser>true</StartWebBrowser>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
+    <DebugSymbols>true</DebugSymbols>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
+    <DebugSymbols>true</DebugSymbols>
+  </PropertyGroup>
+  <ItemGroup>
+    <Content Include="views\index.pug">
+      <SubType>Code</SubType>
+    </Content>
+    <Content Include="views\template\page.pug" />
+    <None Include="server.ts" />
+    <Content Include="tsconfig.json" />
+    <Content Include="package.json" />
+    <Content Include="README.md" />
+  </ItemGroup>
+  <ItemGroup>
+    <Folder Include="public\" />
+    <Folder Include="public\javascript\" />
+    <Folder Include="public\style\" />
+    <Folder Include="routes\" />
+    <Folder Include="src\" />
+    <Folder Include="views\" />
+    <Folder Include="views\template\" />
+  </ItemGroup>
+  <ItemGroup>
+    <TypeScriptCompile Include="routes\index.ts">
+      <SubType>Code</SubType>
+    </TypeScriptCompile>
+  </ItemGroup>
+  <Import Project="$(VSToolsPath)\Node.js Tools\Microsoft.NodejsToolsV2.targets" />
+  <ProjectExtensions>
+    <VisualStudio>
+      <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
+        <WebProjectProperties>
+          <UseIIS>False</UseIIS>
+          <AutoAssignPort>True</AutoAssignPort>
+          <DevelopmentServerPort>0</DevelopmentServerPort>
+          <DevelopmentServerVPath>/</DevelopmentServerVPath>
+          <IISUrl>http://localhost:48022/</IISUrl>
+          <NTLMAuthentication>False</NTLMAuthentication>
+          <UseCustomServer>True</UseCustomServer>
+          <CustomServerUrl>http://localhost:1337</CustomServerUrl>
+          <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
+        </WebProjectProperties>
+      </FlavorProperties>
+      <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}" User="">
+        <WebProjectProperties>
+          <StartPageUrl>
+          </StartPageUrl>
+          <StartAction>CurrentPage</StartAction>
+          <AspNetDebugging>True</AspNetDebugging>
+          <SilverlightDebugging>False</SilverlightDebugging>
+          <NativeDebugging>False</NativeDebugging>
+          <SQLDebugging>False</SQLDebugging>
+          <ExternalProgram>
+          </ExternalProgram>
+          <StartExternalURL>
+          </StartExternalURL>
+          <StartCmdLineArguments>
+          </StartCmdLineArguments>
+          <StartWorkingDirectory>
+          </StartWorkingDirectory>
+          <EnableENC>False</EnableENC>
+          <AlwaysStartWebServerOnDebug>False</AlwaysStartWebServerOnDebug>
+        </WebProjectProperties>
+      </FlavorProperties>
+    </VisualStudio>
+  </ProjectExtensions>
+</Project>

+ 6 - 0
ACPSBooking/ACPSBooking.njsproj.user

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <LastActiveSolutionConfig>Debug|Any CPU</LastActiveSolutionConfig>
+  </PropertyGroup>
+</Project>

+ 25 - 0
ACPSBooking/ACPSBooking.sln

@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.31313.79
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9092AA53-FB77-4645-B42D-1CCCA6BD08BD}") = "ACPSBooking", "ACPSBooking.njsproj", "{B56AC31B-68E5-45FD-A7BC-5D1CA27CC3AA}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{B56AC31B-68E5-45FD-A7BC-5D1CA27CC3AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{B56AC31B-68E5-45FD-A7BC-5D1CA27CC3AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{B56AC31B-68E5-45FD-A7BC-5D1CA27CC3AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{B56AC31B-68E5-45FD-A7BC-5D1CA27CC3AA}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {DC91DC1C-9384-431E-A77E-B8C685B4A5FE}
+	EndGlobalSection
+EndGlobal

+ 3 - 0
ACPSBooking/README.md

@@ -0,0 +1,3 @@
+# ACPSBooking
+
+

+ 22 - 0
ACPSBooking/package.json

@@ -0,0 +1,22 @@
+{
+  "name": "acpsbooking",
+  "version": "0.0.0",
+  "description": "ACPSBooking",
+  "main": "server.js",
+  "author": {
+    "name": ""
+  },
+  "scripts": {
+    "build": "tsc --build",
+    "clean": "tsc --build --clean",
+    "start": "node server"
+  },
+  "devDependencies": {
+    "@types/node": "^14.14.7",
+    "@types/express": "^4.0.37",
+    "typescript": "^4.0.5",
+    "body-parser": "^1.19.0",
+    "express": "^4.14.0",
+    "pug": "^3.0.2"
+  }
+}

+ 11 - 0
ACPSBooking/routes/index.ts

@@ -0,0 +1,11 @@
+/*
+ * GET users listing.
+ */
+import express = require('express');
+const router = express.Router();
+
+router.get('/', (req: express.Request, res: express.Response) => {
+    res.render('index', {});
+});
+
+export default router;

+ 54 - 0
ACPSBooking/server.ts

@@ -0,0 +1,54 @@
+import * as express from 'express';
+import { AddressInfo } from "net";
+import * as path from 'path';
+import * as bodyParser from 'body-parser';
+import route_index from './routes/index';
+
+const debug = require('debug')('my express app');
+const app = express();
+
+// view engine setup
+app.set('views', [path.join(__dirname, 'views'), path.join(__dirname, 'views/template')]);
+app.set('view engine', 'pug');
+
+app.use(express.static(path.join(__dirname, 'public')));
+app.use(bodyParser.json());
+app.use(bodyParser.urlencoded({ extended: true }));
+
+app.use('/', route_index);
+
+// catch 404 and forward to error handler
+app.use((req, res, next) => {
+    const err: any = new Error('Not Found');
+    err['status'] = 404;
+    next(err);
+});
+// error handlers
+
+// development error handler
+// will print stacktrace
+if (app.get('env') === 'development') {
+    app.use((err: any, req: Express.Request, res: any, next: any) => { // eslint-disable-line @typescript-eslint/no-unused-vars
+        res.status(err['status'] || 500);
+        res.render('error', {
+            message: err.message,
+            error: err
+        });
+    });
+}
+
+// production error handler
+// no stacktraces leaked to user
+app.use((err: any, req: any, res: any, next: any) => { // eslint-disable-line @typescript-eslint/no-unused-vars
+    res.status(err.status || 500);
+    res.render('error', {
+        message: err.message,
+        error: {}
+    });
+});
+
+app.set('port', process.env.port || 1337);
+
+const server = app.listen(app.get('port'), function () {
+    debug(`Express server listening on port ${(server.address() as AddressInfo).port}`);
+});

+ 12 - 0
ACPSBooking/tsconfig.json

@@ -0,0 +1,12 @@
+{
+  "compilerOptions": {
+    "module": "commonjs",
+    "target": "es6",
+    "lib": ["es6"],
+    "sourceMap": true,
+    "strict": true
+  },
+  "exclude": [
+    "node_modules"
+  ]
+}

+ 4 - 0
ACPSBooking/views/index.pug

@@ -0,0 +1,4 @@
+extends template/page
+
+block content
+  p Hello World

+ 6 - 0
ACPSBooking/views/template/page.pug

@@ -0,0 +1,6 @@
+doctype html
+html
+  head
+    title
+  body
+    block content

+ 3 - 0
package-lock.json

@@ -0,0 +1,3 @@
+{
+  "lockfileVersion": 1
+}