Code Monkey home page Code Monkey logo

netjs's Introduction

NetJS

NetJS is a javascript engine implemented in .NET It allows for backend development in javascript while still using the .NET framework and running your applications in IIS.

The engine implements all standard javascript features. Next to the standard it provides serverside features like session management, IO, logging, SQL and many more.

Table of contents

Every scope has a buffer for text output, wheneven an expression outputs a value it is converted to a string and added to the buffer. This allows you easily output HTML or text without having to store it in a javascript variable for return.

You can include another javascript or html file. This runs the code in the file and returns the value.

include("logic.js", {loggedIn: true});

include("article.html", {title: "My article", body: "Lorem impsum..."});

You can also import javascript files. This will run the code in that file in the current scope. This can be used to import functions or variables.

import("date.js");
formatDate(new Date());

Sessions are implemented using ASP.NET. You can use the session to store and retrieve values. Unlike SessionStorage in browsers, this session allows you to store all types of variables instread of only strings.

Session.set("userId", user.id);

var userId = Session.get("userId");

With the IO object you can interact with the local filesystem. It allows creating, reading, writing and deleting files.

var text = IO.readText("disclaimer.txt");

IO.writeText("data.json", "{}");

IO.delete("data.json");

The Log object allows you to write text to a log file

Log.write("This is a debug message");

With the HTTP object you can execute get and post requests

var getResponse = HTTP.execute("https://example.com");

var postResponse = HTTP.execute("https://example.com", {
    method: "POST",
    content: JSON.stringify(data)
});

The SQL object allows access to an SQL database. To use this you must define the connection in a file named 'connections.json' in the root of the project. An example:

{
	"Data": {
		"type": "sql",
		"connectionString": "Server=example.com;Database=ExampleName;User Id=sa;Password=test"
	}
}

You can then use the SQL object to execute statements with that connection. If the statement starts with 'SELECT' it will return the data as an array with objects.

var rows = SQL.execute("Data", "SELECT * FROM Table");
  • Copy the release folder and place it somewhere on your computer
  • Rename the release folder to the name of your project
  • Create a new application in IIS with the location set to your project folder
  • Set the security rights for your project folder to allow the IIS user

You should now have a running application. The entry point is the main.js file.

netjs's People

Contributors

boukestam avatar

Stargazers

 avatar Michel du Croix avatar  avatar  avatar well.james avatar Frank Blom avatar  avatar Arjen Stortelder avatar

Watchers

James Cloos avatar Frank Blom avatar  avatar Michel du Croix avatar  avatar

Forkers

arjenst snelzz

netjs's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.