swagger-node only to serve API Docs - node.js

Is there a way to install and start only "reduced" Swagger-node configuration, being able only to serve API specs?
I am not using swagger-node web server, as I have my own.
I would just use swagger-node to visualize nicely the APIs.
UPDATE:
I installed the swagger-ui as explained here: http://idratherbewriting.com/pubapis_swagger/#b-set-up-the-swagger-ui
Unfortunatelly, I cannot change the URL to point to my own file. If I follow the instructions, copy ma YAML in "dist" folder and change the URL to "my.yml" and open index.html in the browser, it tries to fetch "...index.html/my.yml".
How to fix this?

You can start your swagger lerning from : http://swagger.io/swagger-editor/
You can create documentation, API authentication, models etc.
It will create a JSON and you can test your json for UI and functionality over here. http://petstore.swagger.io/
You can download this template and can upload on your domain. its an HTML template so can easily upload on any hosting.

Related

Dowlnload with axios and Browser

I have a vuejs application that works with .net core api. there are some files on API in the API that I want to download. the problem is for security reasons I cannot just put files in wwwroot and create an open link.
So I created a controller which gets the token and some info and after authorization returns the file.
if the file is big I have to wait for Axios to download in javascript and then I can create a link for the browser to Download it.
Is there any way I can download the Result in Browser or third-party softs Like IDM???

How to serve assets from S3 to Client in node.js application

I want to use Amazon S3 to serve my static files (images, fonts,...) to client rather than storing them directly in the web host. I've created a bucket and uploaded my files. I've read other questions and tutorials on how to do this and I got confused since I haven't served files from external storage before.
How do I do this in a secure and standard way? I don't know if this should be done in frontend by directly including URLs to objects or having the server request the files using SDK or other options...
I'm using Node, Express and React.
It is very simple.
configure your bucket to be used to serve static content. You can find the steps here.
configure your build process to add your static files to the react bundle.
build your react app and upload the dist/build folder to the root of the bucket.
That will allow you to serve your static files and your Rect App from S3. Your URL will be a little bit ugly: it will be something like: http://bucket-name.s3-website-region.amazonaws.com.
If you want to have a special URL, like www,yourappname.com you'll need to perform a few more steps:
You'll need to create an SSL public certificate.
You'll need to configure a CloudFront Distribution.
Here you can find more info about these extra steps.
IMPORTANT: S3 does not support Express/Node. For that, you'll need a web server.

NodeJS/Express using Bootstrap for UI elements/interaction

I have an .html file and a corresponding .js file (using Bootstrap) I need to deploy this to Heroku.
I'm really trying to avoid having to rework this entire project, I need more than just bootstrap styling. This project pulls data through an API, and populates based on the data pulled. Input is also needed from user to update the backend through API...
I've tried to find examples of how to accomplish just pulling in html/js into nodeJS/expressJS... but it seems most examples are just to use Bootstrap.css for styling, or there's no actual UI interaction coded in the example.
Any links or input will be greatly appreciated.
If you want to render a html file prepared in the server side. You need a view engine like ejs or pug. You can pass data into the html page. Another way of doing the same thing is a framework called NextJs or NuxtJs but you need to know React or Vue.
You can add bootstrap.css into the public folder and express.static will handle the problem. Or you can use CDN links too.
Then you can add the url of bootstrap.css into the html head.
https://expressjs.com/en/guide/using-template-engines.html
https://expressjs.com/en/starter/static-files.html

using backend files nodejs

Sorry, It might be very novice problem but I am new to node and web apps and just have been stuck on this for couples of days.
I have been working with a API called "Face++" that requires user to upload images to detect faces. So basically users needed to upload images to my webapps backend and my backend would do an API request with that image. I somehow managed to upload the files at my node's backend using tutorial provided below but now I am struggling how to use those image files. I really don't know how to have access to those files. I thought writing just the filepath/filename would help but it did not. I am really new at webapps.
I used tutorial from here: https://coligo.io/building-ajax-file-uploader-with-node/
to upload my files at back-end.
thanks
You can also use the Face++ REST API node client
https://www.npmjs.com/package/faceppsdk
As per in documentation it requires a live URL on web. Then you have to upload your files into remote location (You may upload files to a Amazon S3 Bucket)
And also you check the sample codes from Documentation where you can upload directly to Face++

Need to create an api doc for an existing application written with nodejs/express

I have a few private apis written in plain old express. Time to let it out and provide some api documentation.
What I don't want (at least yet) it to re-write my express app to integrate api documentation into the code. Mainly since I am not sure what framework or spec to use to document my api I don't really want to be locking into one particular thing.
I would like to serve out the doc as part of a sub resource under my api (ie I do not want to run a different server or subdomain). Maybe '/api/docs'. A plus would also be a UI that I could embed within my app that could parse the docs and at the very least provide a nice presentation of the docs in html (api interaction is a plus).
Things like swagger-node are cool, but would require me to re-write all my express code to integrate swagger. At that point I have a big investment and am tightly coupled to swagger.
Is there a way to serve out swagger or iodocs or maybe something else to document my api in a way that is minimally invasive to existing routes?
EDIT:
I could serve out the Swagger spec from a hand written doc. Problem I see is that you have to define basePath in the swagger doc. This does not really allow me to easily deploy under different domains.
There's a wide array of node.js tools to integrate Swagger with your application, and I assume they offer different ways of doing so. You can find a list of such integrations here - https://github.com/webron/swagger-spec/#nodejs - but I can tell you that there are additional tools out there that are not listed there. You can try searching github for swagger and node/express.
As for the manual spec and the basePath - Swagger 2.0 actually solves that for you. You can use the online editor - http://editor.swagger.io - to write your specs in a more human-friendly YAML form, which then you can export to JSON.
Unlike Swagger 1.2 and previous versions, the basePath is now split into three properties - schemes (http, https), host (domain, port) and basePath (the root context of the application). None of these properties are mandatory, and they all default to whatever is serving the swagger.json file (the spec itself). schemes defaults to the scheme service the swagger.json, host defaults to the host used for serving the swagger.json and basePath will be \ unless explicitly specified. I believe this should solve your concerns regarding the basePath.

Resources