RESTful Commit to Github file [closed] - javascript

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I've been looking for quite some time if it is even possible to do this.
I'd like to make a RESTful POST call with a javascript without the use of a server (node) to send a json object in the request body to update a json file in a github repo triggering a commit/push.

Yes, it's possible to do this using the Github API.
The URL must be something like that:
https://api.github.com/repos/{repositoryName}/contents/{path}
repositoryName is the repository where you want to put your file and path its path within this repository.
Regarding the authentication, you need to follow this link https://developer.github.com/v3/#authentication. I successfully tested with basic auth.
You need then to use an HTTP method PUT with content with the following structure:
{
"message": "a commit message",
"content": "bXkgbmV3IGZpbGUgY29udGVudHM="
}
The field content corresponds to the content of your file encoded with base 64.
Hope it helps.
Thierry

Related

Reading a JSON file to edit [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I was given a JSON file and told to read it to get a better understanding of how JavaScript programming works and edit this file to do what I need it to do. It's supposed to be a file to run some cleaning processes on client computers, so I just need to edit it so that they file will run all the processes I want it to run without having to send multiple commands to the computer through my RMM.
When I open the file however in Sublime Text 3 it looks like this. How do I get it to read as JavaScript programming language so I can edit it?
{"os":3,"procedure_type":1,"name":"Clear_PrinterSpool_DNSCache_EventLogs","description":"","version":"2.0","payload":"cX8e1mZa4ffL5OfFuWnR+cqMYnnhpC5Myt22X+nx5dMeS1BYFK5yLlxTPWDPMiw3c0XnZD7Y5zrPIRD9EIxuYLEAa3MYYHZVHhfIUb5MeDifqw3+FHhA/IjFcyL9eSzJ/Nmt2TLu5bPSTQkzqBT9GAdiL0YsDxqn8mpttL0mDCa0g5gJ0vfI41lynD0L8pma6dQ5b3+I+JhSq9irNcHMRrhUkL8dfRUrzIasT/s0q0Ksy0jVu/lcMH+ab0CFlxRMB3aP5dZkBkjTPa4n54pX8yOHejnTbi0qXxVJSBLmFeV4Usw8f/dzbzdR+NN/qSaLP2JU4GXdHjgAIwk0Xb09oFbOhJIu4r7rPku0zLcaq5YXufXXWgzHmBo0AFg1xkGztsfA639dlxZXECxVx4ykMJWnFGl4nowGqsflHSddA4/Q72Nr0ZUm0nM2VAyBhQe8HZ2Z1FwRdBzM8i/YsC6LTGXXjgnn0xin/W2+y+7P+t4n0UFFFAaRT68GuvA/IuwuRjNEIfwhRo5s+qf5D9N1Rbxb/+dvzVVIuwrUIa8HZFHLJM1m4NURNCOTI3aW2o+Qigeah2AOVK4i/mIo94GJ4cnm4odFlli70R8XuKVFzNuKAHfn/TvMorlTdeWaYlLGB67EMtVvGEgSDPCk0mSJkWMzzHm+bxZo+LIAAspBjZuivP68kSm+2FKpMWqlmlKvlx9M+oy+P0koePHx3Ndi4p+Lsm9/mgHyvp3ZdfgmPuMdzOvrMlcibzdAi6e+TohtcQIJpk/yk5OIHgTysbSahwACiwaSLwqLh4SfcQRmmBAn8GoIA+PyD4g3zyErJmaJo6HcpJUcH0g7ytV/rotVvpr+2zW49fPRnCcm8q5pt12qROby42bLUMp/rm03EM+MUKB6I+YzWHENm8tg/O7UDanCyz7DIBbDl4hob8KtL7PA0QDjd9KQ61l/Ld7fNQ9vjNDD+uVaGyDim1ANhwdPMX/nJmvKmVc37XOgEd0AsmicZ8W2FobZpM3yfAdxD3to52N9fwC7T9exYE50RG7+McS+mtd8BRicXe5QfSH5P12GDM9+LaaUVdKzm63FZzhyX/0xpGN97q1VNKPAa6CfO5D/LD21mCrrPeOCeYJ2lHtTo7cW2iu7AXx0WRusz9PX162D+eqeo/ZFmflQv4MpMxnc00pT+QRxX3YZhX/50YU=","payloadChecksum":"d80877609ce0b19f6dcbe3c35d57cd03"}
You can just create a backend call, the URL being pointed to the location of this JSON file.
In the result of that backend call, you will get the contents of the JSON file.

Node-Red save to local file [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
have looked serveral days now to find a Possibility to save data from my MySQL Database to a local file (on the client PC not the server) to analyze the Data there.
I have tried the standard file out node but that only saves to the server File system.
the Flow i am currently using is like this:
If the Button is clicked the data collected by the Function node is send to the Template node.
The last approach i have found some minutes ago was this: Data URI, but I dont get how to put my msg.payload to the file content.
Sorry for this dumb questions but im barely new to HTML and using it in node-red.
Thanks in advance.
Use the http-in and http-out nodes to create a HTTP endpoint that will return the data you want.
If you wire the output from the http-in to the input of the database node then the output from the function node to the input on the http-out.
You can then just point your browser at the URL you configure in the http-in node and the browser should download the data so you can save it locally. You may need to set the Content-Type header to make sure the browser does the right thing with the data.

AngularJS: Import text [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I am not a javascript person so please apologize if this question doesn't make sense:
In my angular project/app.js I have a an array articles which are dictionaries of article elements (description, author, etc...)
var articles = [
{ title : "Article 1",
date : date.toDateString(),
shortDesc : "Short description...",
...
},...
]
This variable is then assigned to an instance variable of the controller
app.controller('BlogController', function () {
this.articles = articles;
});
Now, instead of typing my actual short description into the article dictionary I would like import that text from another file. How do I do that?
Thanks so much in advance!
You can have json file and make call to it by $http.get('data.json'). But then again you're unable to post data to it (client side difficult to write data to file). Else you can install json-server npm module & serve your json file on it, then you can do all CRUD operation through angular's $http service. This's just for mocking purpose or faking REST API, for real project purpose you should have real web services handled by server side technologies (e.g. Java, NodeJS) or create on cloud backend-as-a-service like Firebase, AWS (dynamoDB).

Understanding node.js server directory structure and security [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Sorry if this is a straightforward question, but I was not able to find answer to it online. I have not worked with node.js previously, but am trying to set up a project to play around with. I usually use git to commit any changes to projects repository that is afterwards deployed to the server.
With node am I safe to have a public repo containing files like server.js, config folder, package.json file etc.. basically things that demonstrate how server works.
If I did miss something out please feel free to add info
Yes, the only thing you do not want to push to github are secrets associated with any APIs you may be associated with. Those should be added as environment variables where the server is hosted.

Twitch.tv Api C# Get Streams [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I want to create a Twitch.tv app for desktop Pc. I have read that Twitch api use Json for the streams.
Can someone please explain me how I get the streams into a list? I plan to use C# get the list into a listbox but im stuck and cant continue because I dont know how to get what is available
Another way I was thinking is using Javascript but same problem can someone help me?
The github shows how you can get stream from twitch. First you send a request like shown on github "curl -H 'Accept: application/vnd.twitchtv.v2+json' -X GET https://api.twitch.tv/kraken/streams/test_channel" then you will get a JSON file (that contains all the information you need) as a response, you the read the file and use it in your application

Categories

Resources