Comments (9)
I would also be open to allowing a command-line option to specify the API path.
I already have a local branch ready to PR but we are stuck with CI-Travis and Appveyor complaining for the node-oniguruma
problem.
As soon as we can PR again, will submit the branch with the CLI api path option
from jus.
That does seem a little silly, doesn't it?
The trivial solution to this is to serve the /api
endpoint somewhere else, at say /jus-api
instead. This would be easy and have minimal impact, since the jus
core library doesn't use that endpoint outside of tests.
However, I don't know if any jus
users have scripts that reference the existing api
endpoint. I wouldn't want to introduce a breaking change for them. The other possibility is to make the api
route configurable, through a command-line option probably. This has the advantage that it doesn't break anything, but it is less convenient for those who need the /api
endpoint for something else.
@zeke , @wmhilton , any preference or insight here?
from jus.
I definitely don't think it's silly. :)
Of course it's easy to bypass the limitation if you're willing to settle for a less clean URL. I think however that the /api
endpoint is one that many users might want for themselves, since it's very common for library docs to use it (examples: https://webpack.js.org/api, https://emberjs.com/api, https://pugjs.org/api/getting-started.html)
It's obviously not a deal breaker, but still a bit annoying. I agree that it would be nice to make the current api
route configurable with some flag. Alternatively choose something less generic, if you want to emphasise the "convention over configuration" philosophy.
Just my ยข2!
from jus.
A third option could be that, when hitting the /API endpoint, Jus first checks whether the user has defined that route themselves in the file structure. If they have, then load that page. If not, just show the default JSON data as it does now.
Unless the /api endpoint is used internally by the library for some reason I think that could be a good solution too.
from jus.
...is to make the api route configurable
cli.js
. . .
process.env.JUS_API_ENDPOINT_NAME = args.api || args.a || 'api'
. . .
routes.js
. . .
server.redirects = require('./redirects')(server)
server.get('/' + process.env.JUS_API_ENDPOINT_NAME, (req, res) => {
res.json(server.context)
})
server.get('/' + process.env.JUS_API_ENDPOINT_NAME + '/*', (req, res) => {
var href = req.params[0].replace(/^files/, '')
var page = server.context.pages.find(page => page.href === href)
. . .
Usage
$ jus serve . --api jusapi
Rationale
- Not include leading slash on the argument cause
minimist
does some path conversions (they could be solved bypath.resolve(process.cwd()...
but is to much for a simple configurable directory name)
Note:
@zeke @jdormit @wmhilton We need to do something about node-oniguruma
breaking problem. I was unable to PR this simple api change (as neither #70 ) cause of failing test due to node-oniguruma
dependency. Remeber master jus
is not working for new installations with Node below 6.4 !
from jus.
@elingerojo Oh man, I hadn't tried running jus
with Node v4. Is there a reason you are using such an old version? Do you think it's important that we support such an old version?
from jus.
@jdormit
Not really but...
...we are unable to do PR without CI-Travis and Appveyor complaints since the 20th of April because node-oniguruma
- we should update dependencies accordingly...
- ... change pagkage.json engines
- ...and more important, change .travis.yml here and appveyor.yml here
I already submitted a PR to atom/node-oniguruma
but they have not even commented about it.
As a side note, this "unable to PR" is dragging me on updating you guys about the #70 alpha-like-jus-app
branch and the #61
from jus.
Hey people sorry for the silence. I've been offline on parental leave for the last month. ๐ด
I work with the atom team at GitHub, so I can take a look at that oniguruma PR and see if we can get a new version of it out. If it ends up being difficult, I would be open to releasing a new major version of jus that intentionally drops node 4 support.
I would also be open to allowing a command-line option to specify the API path. Or, as @t4t5 suggested, checking whether the user has defined the api route.
@t4t5 would you be interesting in submitting a PR to support that behavior?
from jus.
Just created an api-configurable-endpoint branch at my jus fork.
- Added an optional CLI argument to specify the API endopoint instead of the default
'/api'
- Dumped Node 4 support in favor of Node 6 (just to get travis working 'cause
node-oniguruma
breaking problem)
Issues before doing a PR to jus/jus
-
Should I include user facing instructions for the optional argument? I do not want to brake the "jus no configuration magic" but maybe an "Advanced Users" section could do the trick.
-
Dumping Node 4 support should be discussed first
from jus.
Related Issues (20)
- Consider using `consolidate.js` library for abstracting different template options
- Feature: Add YAML support for 'page' type files (not just for 'datafile' type) HOT 1
- List of excluded files HOT 8
- Inkscape-generated SVG error from `image-size` library HOT 1
- Don't try to parse `svg` fonts as images HOT 4
- Moved jus repos to a GitHub organization! HOT 1
- Replaceable Markdown processor HOT 2
- path-exists should be a dependency, not a dev-dependency?
- Modularizing jus HOT 19
- Serve a unique favicon.ico per project HOT 12
- Automagically generate thumbnails HOT 6
- Remove old 404 ยฏ\_(ใ)_/ยฏ message
- Remove unneeded 'href-type' dependency
- Can we import CSS files from node_modules? HOT 1
- Allow Sass Imports HOT 1
- jus development stalled by Node 4 support HOT 3
- Support for more handlebars helpers HOT 2
- Dynamic pages, filtering data, custom helpers, and other templating languages? HOT 8
- README is not up to date
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jus.