p4a
It is a simple nodejs server integrated with body, cookie parsing, file upload handler, cors connection etc.
Create simple server:
; ;server.listen;
Serve static files
Serves static files from the given path
server.serveStatic__dirname+'/public';
Create Api over http
Make get
and post
requests
; endpoint.get'/',
Request
and Response
Access Express you can access express req
and res
too using req.req
and res.res
in callback
; endpoint.get'/',
Access requested body, cookies, form with files from the request
You can access requested body, cookies, form with files from the request without mounting any middleware
; endpoint.post'/',;
Endpoint chaining
; ; ;; college.hookup"library", library;college.hookup"department", department; endpoint.hookup"college", college
Establish real time connection over socket
; socket.to'/chat',;
Configure filesystem
Configure where to upload the file for more information see the documentation
server.fileSystem.Config;
Allow origins to access server
Allow all origins
server.allowOrigins"*"
Allow single origin
server.allowOrigins"http://localhost:4200"
Allow multiple origins
server.allowOrigins
Full example
; ; // Allow origin to access serverserver.allowOrigins'http://localhost:4200'; // Configure file systemserver.fileSystem.Config; ; // Handle http requests // Static form endpoint.serveStatic__dirname+'/docs', ; //http://localhost:8088/hiendpoint.get'/hi',; endpoint.post'/',; ; // Handle sockets //Connect socket.io on http://localhost:8088/namespacesocket.to'/namespace',; // start server on port 8088server.start;
Simple static files serving with p4a
Serve static files
; ; // Static form server.serveStatic__dirname+'/docs'; // start server on port 8088server.start;