2.0.3 • Published 5 years ago

nk-node v2.0.3

Weekly downloads
6
License
ISC
Repository
github
Last release
5 years ago

NK-Node

NK Central Libraries for NodeJS

How to install the library

npm i nk-node --save

How to include the library

const NK = require( "nk-node" );

How to use express

The express server can also be the SSL server (like a local web server), provide the location based on the domain name from let's encrypt

NK.xpr.load();
NK.xpr.load( "mydomain.com" );
NK.xpr.add( "get", "/user/:id", ( res, ip, requestedDATA, cookieOrSession, filesPosted, hostname ) => {
				//the res item is the same as always
				//ip is the Source IP of the request
				//requestedDATA is the paramaters, already formatted, in the request, in this example you can use requestedDATA.id the data is auto formatted to an object regardless or source
				//cookieOrSession is the object of the cookie or override session function
				//filesPosted is the object of the files posted from the request
				//hostname is the name of the host in the request. this is useful when using virtual hosts in the same node core
		if( parseInt( requestedDATA.id ) > 0 ) {
			res.json( { user: "valid" } );
		} else {
			res.status( 400 ).json( { user: "invalid" } );
		}
});

The express server can also process user authentication

NK.xpr.load( "mydomain.com" );
NK.xpr.add( "get", "/user/:id", ( res, ip, requestedDATA, cookieOrSession, filesPosted, hostname ) => {
				//the res item is the same as always
				//ip is the Source IP of the request
				//requestedDATA is the paramaters, already formatted, in the request, in this example you can use requestedDATA.id the data is auto formatted to an object regardless or source
				//cookieOrSession is the object of the cookie or override session function
				//filesPosted is the object of the files posted from the request
				//hostname is the name of the host in the request. this is useful when using virtual hosts in the same node core
		if( parseInt( requestedDATA.id ) > 0 ) {
			res.json( { user: "valid" } );
		} else {
			res.status( 400 ).json( { user: "invalid" } );
	}
}, ( headers ) => ( headers.auth == "isvalid" ) );

Happy Coding!

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

1.1.12

5 years ago

1.1.9

5 years ago

1.1.11

5 years ago

1.1.10

5 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.0.26

5 years ago

1.0.25

5 years ago

1.0.24

5 years ago

1.0.23

5 years ago

1.0.22

5 years ago

1.0.21

5 years ago

1.0.19

5 years ago

1.0.18

5 years ago

1.0.17

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago