خرید بک لینک

Vote count: 0

I get this error from the 1.8.10 ts compiler in the context of a nodejs / express project:

Error:(17, 23) TS2345: Argument of type 'typeof "/Users/ME/Documents/Apps_And_Sites/Js_Apps/site/apps/directory/directory_contr...' is not assignable to parameter of type 'Router'. Property 'param' is missing in type 'typeof "/Users/ME/Documents/Apps_And_Sites/Js_Apps/site/apps/directory/directory_contr...'.

Here is the controller file:

Import * as express from "express"
import * as directory_models from "./directory_models"
import * as forms from "formidable"

let directory_router = express.Router()  // HERE /////////


// GET
directory_router.get("/list", function (req, res) {

    function callback (err, data) { // function definition
        res.render("directory_views.ejs", {datatest: data})
    }

    directory_models.read(
        `SELECT link_title 
        FROM 
        links`,
        callback)
})

// POST
directory_router.route("/create")

// Display form page
    .get(function (req, res) {
        res.render("directory_post.ejs")
    })

    // Process form
    .post(function (req, res) {
        let form = new forms.IncomingForm()
        form.parse(req, function (err, fields, files) {
            directory_models.create(fields)
        })
        res.render("directory_post.ejs")
    })


module.exports = directory_router

And here is the entry file of the web app:

import * as express from "express"
import * as lodash from "lodash"
import * as directory from "./apps/directory/directory_controller"


// Non require variables
let app          = express()
let port         = process.env.PORT || 3002
import * as forms from "formidable"    


app.use("/directory", directory) // ERROR HERE ////////
app.set("views", [__diame + "/apps/directory/views/", "views"])
app.set("view engine", "ejs")

app.listen(port, function () {
  console.log("Server is listening on port:" + port)
})

It doesn't prevent the project to work properly, but still I would like to understand and get rid of this error. Do you know how ?

asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 8 ارديبهشت 1395 ساعت: 15:55

صفحه بندی