I'm looking for ways/best practices on how to structure a dynamic web site I'm planning to do with nim. Looks like I'll be using jester for the backend, with karax for the frontend. Ideally they would live in the same repo and share some of the code, for instance the types. So, I'm looking for something like:
- project root
- core
- be
- fe
where both be and fe would import core.
I'm having troubles organizing this using nimble. I looked at the forum's repository, but it seems like it treats the frontend as a special case.
Any advise?
IMO, there is no need to think too much on the file organization, you will find how to organize them when the code size grow. One little trick I found useful is to add a --path to nim.cfg and create a common.nim that export frequently used packages. So that I can easily import packages with import common and less code to change when moving/renaming files.
File structure:
- src
- core
- foo.nim
- bar.nim
- common.nim
- nim.cfg
nim.cfg:
--path:"src/core"
common.nim
import foo, bar
export foo, bar
I've been working on a project lately with Jester, and have a src/ directory for Nim source and web/ directory for JS, CSS, etc:
I usually place HTML templates in "templates/<name>.tmpl"
See https://nim-lang.org/docs/filters.html#available-filters-stdtmpl-filter