openassistive / OpenATBackend

Back end api for Open Assistive built using nodeJS.
https://api.openassistive.org
4 stars 1 forks source link

Need httpfile service #2

Closed willwade closed 7 years ago

willwade commented 7 years ago

Pass in a URL. If ends with _openat.md then deal with it. This would be the same format as a item post.

hosseinzoda commented 7 years ago

@willwade Can you elaborate?

willwade commented 7 years ago

In https://github.com/openassistive/OpenATBackend/blob/master/js/services/index.js#L52 need something like

{ name: 'httpfile', baseUrl: '/[^/]*(?:openat\.md)$', prefix: '', projectPath: { skip: 0, take: 1 } },

And then in js/services/httpfile.js

`'use strict'; var contentCreator = require('../functions'); var toMarkdown = require('to-markdown');

exports.handler = function(req, res, next) { var url = req.projectUrl;

var http = require('http'); var request = http.get(url); // download file // validate md // convert to json

return res .status(500) .json({ error: "Sorry. There was problems retrieving the information."}); }; `

(thats psudocode obviously!)

hosseinzoda commented 7 years ago

How about projects to add a file in their repo (thinking of github) and we can check that file... instead of new url like package.json/bower.json and then we can implement submit with cmd. I'm not sure about other services

hosseinzoda commented 7 years ago

Pass in a URL. If ends with _openat.md then deal with it. This would be the same format as a item post.

Instead of _openat.md i will set .md, only the extension. for it to work on a situation in #3

hosseinzoda commented 7 years ago

Done.

Summary

  1. has initial validator
  2. prepares content for save command
  3. follows relative image path to turn it in absolute url image_download variable
  4. error handling