playground-tools
playground-tools copied to clipboard
Allow express app to be (optionally) passed to start-server
What?
- Add optional
app
arg tostartServer
that is express app.
Why?
I wanted to see if I could integrate this with an existing express app. I was able to make it work with one small change that I think is a useful change. Would allow using WordPress for part of a node application and or easily plug this package into existing application
This is what I am thinking:
import {
getWpNowConfig,
startServer
} from '@wp-now/wp-now';
const options = await getWpNowConfig({});
const app = express();
app.get('/api', (req, res) => {
res.json({message:"Hi Roy"})
});
const { url } = await startServer({...options,app});
console.log({url})
How?
- Makes it optional arg
- Uses that app if needed
Testing Instructions
No Changes test
- Check out the branch.
-
npx nx preview wp-now start
- Should work as-is, no changes.
Works this way test
- Check out the branch.
- Link
npm link @wp-now/wp-now
https://docs.npmjs.com/cli/v9/commands/npm-link - Make a new project
- Install this wp-now locally
- Test it with above example code