«Система не определена» при создании RESTful API с помощью TypeScript - PullRequest
0 голосов
/ 08 мая 2019

Я пытаюсь создать RESTful API, используя TypeScript и SystemJS

// index.ts
// Import express
import express from "express"
// Imports routes
import apiRoutes from "api-routes.js"

// Initialise the app
const app = express()

// set up server port
const port = process.env.port || 3000

// Send message for default URL
app.get('/', (request, response) => response.send('Hello World with Express.'))

// Launch app to listen to specified port
app.listen(port, function(){
    console.log(`Listening on port ${port}`)
})

// Use API routes in the app.
app.use('/api', apiRoutes)

Этот файл компилируется в javascript

System.register(["express", "api-routes.js"], function (exports_1, context_1) {
    "use strict";
    var express_1, api_routes_js_1, app, port;
    var __moduleName = context_1 && context_1.id;
    return {
        setters: [
            function (express_1_1) {
                express_1 = express_1_1;
            },
            function (api_routes_js_1_1) {
                api_routes_js_1 = api_routes_js_1_1;
            }
        ],
        execute: function () {
            // import * as express from "express"
            // import * apiRoutes from './build/'
            // Initialise the app
            app = express_1.default();
            // set up server port
            port = process.env.port || 3000;
            // Send message for default URL
            app.get('/', function (request, response) { return response.send('Hello World with Express.'); });
            // Launch app to listen to specified port
            app.listen(port, function () {
                console.log("Listening on port " + port);
            });
            // Use API routes in the app.
            app.use('/api', api_routes_js_1.default);
        }
    };
});

Я получаю следующую ошибку

enter image description here

В нем говорится, что я не могу сослаться system из системного модуля.Вот ссылка на мой репо

В html я импортирую SystemJS примерно так:

<script src="node_modules/systemjs/dist/system.js"></script>

Как импортировать SystemJS вмой index.ts файл?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...