lukejacksonn / lukejacksonn/servor
Add flow support
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.1k
- Forks
- 68
- PR merge metrics
- No merged PRs in 30d
Description
I know this project comes with no dependencies at the moment, but having static typing is very important to me.
Flowtype is a nice fit for this project since `flow-remove-type` is a very simple tool.
I have a fork which adds support for flow: https://github.com/lukejacksonn/servor/compare/master...taylorgoolsby:master
If you still want to keep no dependencies, how do you feel about implementing a hook/plugin system? I have something like this in mind:
```
// Add `transform` as a parameter to `servor`:
module.exports = async ({
root = '.',
module = false,
fallback = module ? 'index.js' : 'index.html',
reload = true,
static = false,
inject = '',
credentials,
port,
transform
} = {}) => {
// sendFile passes files through `transform`:
const sendFile = (res, status, file, ext, encoding = 'binary') => {
if (transform) {
file = transform(file, ext)
}
if (['js', 'css', 'html', 'json', 'xml', 'svg'].includes(ext)) {
res.setHeader('content-encoding', 'gzip');
file = zlib.gzipSync(utf8(file));
encoding = 'utf8';
}
res.writeHead(status, { 'content-type': mimeTypes(ext) });
res.write(file, encoding);
res.end();
};
// flowtype + servor using the transform plugin:
const flowRemoveTypes = require('flow-remove-types');
const servor = require('servor');
const instance = await servor({
root: '.',
fallback: 'index.html',
module: false,
static: false,
reload: false,
inject: '',
credentials: null,
port: 8080,
transform: (file, ext) => {
if (ext === 'js') {
file = flowRemoveTypes(file).toString()
}
return file
}
});
```
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the existing servor request path, especially the sendFile logic shown in the issue, and compare it with the linked fork. Clarify whether the goal is direct Flow support or a general transform hook, then define the supported configuration and verify that transformed JavaScript is served correctly without breaking the dependency-free setup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100