Skip to content

An Express.js like nuget package for building REST APIs using .NET

Notifications You must be signed in to change notification settings

meni3a/ExpressSharp

Repository files navigation

ExpressSharp

An Express.js like NuGet package for building REST APIs using .NET

Installation

You can install this package using the NuGet package manager.

How to use

Using c# 9 and above, you can take advantage of top-level statements capability, and use the code like that:

var app = new express();


app.use("/some", (req, res) => {
    Console.WriteLine("middleware");
});

app.get("/some", (req, res) => {
    res.status(200).send(req.query["someParam"]);
});

app.post("/index", (req, res) => {
    res.status(400).send(req.body);
});


app.listen(8070, () => {
    Console.WriteLine("server is listing..");
});

For other versions, just insert inside a function:

class Program
    {
        static void Main(string[] args)
        {
            var app = new express();

            
            app.use("/some", (req, res) => {
                Console.WriteLine("middleware");
            });

            app.get("/some", (req, res) => {
                res.status(200).send(req.query["someParam"]);
            });

            app.post("/index", (req, res) => {
                res.status(400).send(req.body);
            });


            app.listen(8070, () => {
                Console.WriteLine("server is listing..");
            });
            
            
            Console.ReadLine();
        }
    }

License

MIT

About

An Express.js like nuget package for building REST APIs using .NET

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages